ClickHandler.cs 751 B

12345678910111213141516171819202122
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Sirenix.OdinInspector;
  5. namespace KairoEngine.UI.InteractionHandler
  6. {
  7. [HideMonoScript]
  8. public class ClickHandler : MonoBehaviour
  9. {
  10. [InfoBox("Control this button dynamicly thru a parent object that implements the ClickHandler interface. Trigger the OnClick function on this script thru the Button Component.")]
  11. public string title = "";
  12. [ShowInInspector, ReadOnly, ShowIf("@receiver != null")] public IClickHandler receiver;
  13. public void OnClick()
  14. {
  15. if(receiver != null) receiver.OnClick(title);
  16. //else Debug.LogError("ClickHandler has no receiver!", this.gameObject);
  17. }
  18. }
  19. }