using System.Collections; using System.Collections.Generic; using UnityEngine; using AX.MessageSystem; using System; using AX.InputSystem; [RequireComponent(typeof(CloneButtonTest))] public class CancelCloneBtnSelected : MonoBehaviour { private CloneButtonTest cloneButton; // Use this for initialization void Start () { cloneButton = this.GetComponent(); } // Update is called once per frame void Update () { } void OnEnable() { MessageDispatcher.AddListener("CANCEL_CLONEBTN_SELECTED_COMMAND", Execute); } void OnDisable() { MessageDispatcher.RemoveListener("CANCEL_CLONEBTN_SELECTED_COMMAND", Execute); } void OnDestroy() { MessageDispatcher.RemoveListener("CANCEL_CLONEBTN_SELECTED_COMMAND", Execute); } private void Execute(IMessage obj) { cloneButton.isOn = false; var arg = (CloneCmdArgs)obj.Data; if (cloneButton.isOn) { cloneButton.Select(arg); } } }