PinBallUIBase.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using JetBrains.Annotations;
  4. using UnityEngine;
  5. public interface IPinBallUIBase
  6. {
  7. void ShowUI(object[] args);
  8. void BroadcastUI(object[] args);
  9. void HideUI();
  10. }
  11. public enum PinBallUILevel
  12. {
  13. BG,
  14. Content,
  15. Pop,
  16. }
  17. public class PinBallUIBase : MonoBehaviour, IPinBallUIBase
  18. {
  19. private bool m_bIsInit;
  20. protected Canvas canvas;
  21. public PinBallUILevel uILevel = PinBallUILevel.Content;
  22. public bool IsInit
  23. {
  24. get { return m_bIsInit; }
  25. }
  26. protected virtual void Init()
  27. {
  28. canvas = this.GetComponent<Canvas>();
  29. }
  30. public void ShowUI(object[] args)
  31. {
  32. if (!m_bIsInit)
  33. {
  34. m_bIsInit = true;
  35. Init();
  36. }
  37. //this.gameObject.SetActive(true);
  38. this.canvas.enabled = true;
  39. ShowUIOpt(args);
  40. }
  41. protected virtual void ShowUIOpt(object[] args)
  42. {
  43. }
  44. public void BroadcastUI(object[] args)
  45. {
  46. Broadcast(args);
  47. }
  48. protected virtual void Broadcast(object[] args)
  49. {
  50. }
  51. public void HideUI()
  52. {
  53. HideUIOpt();
  54. //this.gameObject.SetActive(false);
  55. this.canvas.enabled = false;
  56. }
  57. protected virtual void HideUIOpt()
  58. {
  59. }
  60. }