UiSystemElement.cs 951 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Sirenix.OdinInspector;
  5. namespace KairoEngine.UI
  6. {
  7. [HideMonoScript]
  8. public class UiSystemElement : MonoBehaviour, IUiSystemElement
  9. {
  10. public string elementTitle = "New UI Element";
  11. public RectTransform targetRectTransform;
  12. public bool isVisible = true;
  13. public void Hide()
  14. {
  15. targetRectTransform.gameObject.SetActive(false);
  16. isVisible = false;
  17. }
  18. public void Show()
  19. {
  20. targetRectTransform.gameObject.SetActive(true);
  21. isVisible = true;
  22. }
  23. public bool IsVisible() => isVisible;
  24. private void OnDisable()
  25. {
  26. UiManager.UnregisterElement(this);
  27. }
  28. private void OnEnable()
  29. {
  30. UiManager.RegisterElement(elementTitle, this, this.transform, isVisible);
  31. }
  32. }
  33. }