UIPanelBase.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using UnityEngine;
  3. public class UIPanelBase : MonoBehaviour
  4. {
  5. private Transform m_Transform;
  6. private GameObject m_Go;
  7. private bool m_IsActive;
  8. public Transform CacheTransform
  9. {
  10. get
  11. {
  12. if (this.m_Transform == null)
  13. {
  14. this.m_Transform = base.transform;
  15. }
  16. return this.m_Transform;
  17. }
  18. }
  19. public GameObject CacheGameObject
  20. {
  21. get
  22. {
  23. if (this.m_Go == null)
  24. {
  25. this.m_Go = base.gameObject;
  26. }
  27. return this.m_Go;
  28. }
  29. }
  30. public bool IsActive
  31. {
  32. get
  33. {
  34. this.m_IsActive = this.m_Go.activeSelf;
  35. return this.m_IsActive;
  36. }
  37. }
  38. private void Awake()
  39. {
  40. this.OnAwake();
  41. }
  42. private void Start()
  43. {
  44. this.OnStart();
  45. }
  46. public void Show(object param = null)
  47. {
  48. m_IsActive = true;
  49. this.CacheGameObject.SetActive(true);
  50. this.OnShow(param);
  51. }
  52. protected virtual void OnAwake()
  53. {
  54. }
  55. protected virtual void OnStart()
  56. {
  57. }
  58. protected virtual void OnShow(object param)
  59. {
  60. }
  61. public virtual void Hide()
  62. {
  63. this.m_IsActive = false;
  64. CacheGameObject.SetActive(false);
  65. }
  66. public virtual void OnDestroy()
  67. {
  68. UnityEngine.Object.Destroy(base.gameObject);
  69. }
  70. }