StartSetPlaneHeightButton.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class StartSetPlaneHeightButton : MonoBehaviour
  6. {
  7. // Start is called before the first frame update
  8. void Start()
  9. {
  10. SafetyAreaManager.Instance.OnBeginSetSafeArea += OnBeginSetSafeArea;
  11. SafetyAreaManager.Instance.OnFinishSetSafeArea += OnFinishSetSafeArea;
  12. this.GetComponent<Button>().onClick.AddListener(OnButtonClick);
  13. }
  14. private void OnDestroy()
  15. {
  16. this.GetComponent<Button>().onClick.RemoveListener(OnButtonClick);
  17. SafetyAreaManager.Instance.OnBeginSetSafeArea -= OnBeginSetSafeArea;
  18. SafetyAreaManager.Instance.OnFinishSetSafeArea -= OnFinishSetSafeArea;
  19. }
  20. private void OnButtonClick()
  21. {
  22. SafetyAreaManager.Instance.StartSetSafetyAreaHeight();
  23. }
  24. private void OnBeginSetSafeArea()
  25. {
  26. this.gameObject.SetActive(false);
  27. }
  28. private void OnFinishSetSafeArea()
  29. {
  30. this.gameObject.SetActive(true);
  31. }
  32. }