UiSystemElement.cs 923 B

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