using NodeCanvas.DialogueTrees; using NodeCanvas.Framework; using System.Collections; using System.Collections.Generic; using Unity.VisualScripting; using UnityEngine; namespace Ether { public enum NPCFunctionType { Dialogue, } [RequireComponent(typeof(Rigidbody2D))] public class NPCController : MonoBehaviour { Blackboard blackboard; private DialogueTreeController dialogueTree; private Canvas NPCCanvas; private Transform NPCFunction; private void Start() { dialogueTree = GetComponent(); blackboard = GetComponent(); NPCCanvas = transform.Find("NPCCanvas").GetComponent(); NPCFunction = NPCCanvas.transform.Find("NPCFunction"); ButtonEx dialogueBtn = NPCFunction.Find("DialogueBtn").GetComponent(); dialogueBtn.OnClick.AddListener(() => { blackboard.SetVariableValue("state", 2); }); } public void SetNPCFunction(bool isShow, NPCFunctionType type = NPCFunctionType.Dialogue) { NPCFunction.gameObject.SetActive(isShow); } } }