BaseUI.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using System;
  2. using UnityEngine;
  3. public class BaseUI : AbstractController
  4. {
  5. protected string m_UIName = string.Empty;
  6. private Transform m_Transform;
  7. private GameObject m_Go;
  8. public string UIName
  9. {
  10. get
  11. {
  12. return this.m_UIName;
  13. }
  14. set
  15. {
  16. this.m_UIName = value;
  17. }
  18. }
  19. public Transform CacheTransform
  20. {
  21. get
  22. {
  23. if (this.m_Transform == null)
  24. {
  25. this.m_Transform = base.transform;
  26. }
  27. return this.m_Transform;
  28. }
  29. }
  30. public GameObject CacheGameObject
  31. {
  32. get
  33. {
  34. if (this.m_Go == null)
  35. {
  36. this.m_Go = base.gameObject;
  37. }
  38. return this.m_Go;
  39. }
  40. }
  41. public void Show(object param = null)
  42. {
  43. this.CacheGameObject.SetActive(true);
  44. this.OnShow(param);
  45. }
  46. public void Show(WarningUI.OnYesClick onYesClick, object param = null)
  47. {
  48. this.CacheGameObject.SetActive(true);
  49. this.OnShow(onYesClick, param);
  50. }
  51. public void Show(WarningUI.OnYesClick onYesClick, WarningUI.OnNoClick onNoClick, object param = null)
  52. {
  53. this.CacheGameObject.SetActive(true);
  54. this.OnShow(onYesClick, onNoClick, param);
  55. }
  56. public void Hide()
  57. {
  58. this.CacheGameObject.SetActive(false);
  59. this.OnHide();
  60. }
  61. public bool IsShow()
  62. {
  63. return this.CacheGameObject.activeSelf;
  64. }
  65. private void Awake()
  66. {
  67. this.OnAwake();
  68. }
  69. public void UIInit()
  70. {
  71. this.OnInit();
  72. }
  73. protected virtual void OnShow(object param)
  74. {
  75. }
  76. protected virtual void OnShow(WarningUI.OnYesClick onYesClick, object param)
  77. {
  78. }
  79. protected virtual void OnShow(WarningUI.OnYesClick onYesClick, WarningUI.OnNoClick onNoClick, object param)
  80. {
  81. }
  82. protected virtual void OnHide()
  83. {
  84. }
  85. protected virtual void OnInit()
  86. {
  87. }
  88. protected virtual void OnAwake()
  89. {
  90. }
  91. protected virtual void OnDestroy()
  92. {
  93. }
  94. }