void Start() { clickedState = InteractiveElement.GetState("Clicked"); if (clickedState != null) { ClickedEvents clickedEvents = InteractiveElement.GetStateEvents <ClickedEvents>("Clicked"); clickedEvents.OnClicked.AddListener(() => { Debug.Log($"{gameObject.name} Clicked"); }); } }
/// <summary> /// Add Clicked state with event listeners. /// </summary> public void AddClickedState() { interactiveElement.AddNewState("Clicked"); ClickedEvents clickedEvent = interactiveElement.GetStateEvents <ClickedEvents>("Clicked"); clickedEvent.OnClicked.AddListener(() => { Debug.Log($"{gameObject.name} Clicked"); }); // Note: // To customize the timing of when the clicked state is triggered use: // interactiveElement.TriggerClickedState(); }