UIToggleObjectCustomStateWidget.cs 821 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using UnityEngine;
  3. namespace Fort23.Mono
  4. {
  5. public class UIToggleObjectCustomStateWidget : UIToggleWidgetBasic
  6. {
  7. public CustomStateController CustomStateController;
  8. [HideInInspector] public Action showCallback;
  9. [HideInInspector] public Action hideCallback;
  10. private void Awake()
  11. {
  12. if (CustomStateController == null)
  13. {
  14. CustomStateController = gameObject.GetComponent<CustomStateController>();
  15. }
  16. }
  17. public override void Show()
  18. {
  19. CustomStateController?.ChangeState(1);
  20. showCallback?.Invoke();
  21. }
  22. public override void Hind()
  23. {
  24. CustomStateController?.ChangeState(0);
  25. hideCallback?.Invoke();
  26. }
  27. }
  28. }