ModalWindowController.cs 931 B

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