StationaryAreaUI.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 Text confirmStationaryAreaTitleText;
  25. public Text confirmStationaryAreaDescribeText;
  26. public Text confirmBtnText;
  27. public Text redrawPlayAreaBtnText;
  28. public void Init()
  29. {
  30. confirmButton.onClick.AddListener(() =>
  31. {
  32. OnConfirmClick?.Invoke();
  33. });
  34. cancelButton.onClick.AddListener(() =>
  35. {
  36. OnCancelClick?.Invoke();
  37. });
  38. switchToPlayAreaButton.onClick.AddListener(() =>
  39. {
  40. OnSwitchToPlayAreaClick?.Invoke();
  41. });
  42. SafetyAreaLanguageManager.Instance.onLanguageChange += ChangeLanguageText;
  43. ChangeLanguageText();
  44. }
  45. public void ChangeLanguageText()
  46. {
  47. confirmStationaryAreaTitleText.text = SafetyAreaLanguageManager.Instance.GetWord(106025);
  48. confirmStationaryAreaDescribeText.text = SafetyAreaLanguageManager.Instance.GetWord(106026);
  49. confirmBtnText.text = SafetyAreaLanguageManager.Instance.GetWord(10092);
  50. redrawPlayAreaBtnText.text = SafetyAreaLanguageManager.Instance.GetWord(106035);
  51. }
  52. public void Release()
  53. {
  54. confirmButton.onClick.RemoveAllListeners();
  55. cancelButton.onClick.RemoveAllListeners();
  56. switchToPlayAreaButton.onClick.RemoveAllListeners();
  57. SafetyAreaLanguageManager.Instance.onLanguageChange -= ChangeLanguageText;
  58. }
  59. }