StationaryAreaUI.cs 1021 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. public class StationaryAreaUI : MonoBehaviour
  5. {
  6. public Action OnSwitchToPlayAreaClick
  7. {
  8. get;
  9. set;
  10. }
  11. public Action OnConfirmClick
  12. {
  13. get;
  14. set;
  15. }
  16. public Action OnCancelClick
  17. {
  18. get;
  19. set;
  20. }
  21. public Button switchToPlayAreaButton;
  22. public Button confirmButton;
  23. public Button cancelButton;
  24. public void Init()
  25. {
  26. confirmButton.onClick.AddListener(() =>
  27. {
  28. OnConfirmClick?.Invoke();
  29. });
  30. cancelButton.onClick.AddListener(() =>
  31. {
  32. OnCancelClick?.Invoke();
  33. });
  34. switchToPlayAreaButton.onClick.AddListener(() =>
  35. {
  36. OnSwitchToPlayAreaClick?.Invoke();
  37. });
  38. }
  39. public void Release()
  40. {
  41. confirmButton.onClick.RemoveAllListeners();
  42. cancelButton.onClick.RemoveAllListeners();
  43. switchToPlayAreaButton.onClick.RemoveAllListeners();
  44. }
  45. }