BaseUIForm.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace LoyalSoftSDK
  5. {
  6. public enum UIType
  7. {
  8. Normal,
  9. Float,
  10. Loading
  11. }
  12. public class BaseUIForm : MonoBehaviour
  13. {
  14. //从哪个窗口打开的,无操作返回时使用打开上一级的
  15. private BaseUIForm parent;
  16. public UIType curUIType;
  17. // Use this for initialization
  18. public virtual void Hiding()
  19. {
  20. this.gameObject.SetActive(false);
  21. }
  22. public virtual void Display(BaseUIForm _parent,Dictionary<string,string> data)
  23. {
  24. if (this.gameObject.transform.parent.transform.parent && !this.gameObject.transform.parent.transform.parent.gameObject.activeInHierarchy)
  25. {
  26. this.gameObject.transform.parent.transform.parent.gameObject.SetActive(true);
  27. }
  28. // Debug.Log(this.gameObject.transform.parent + " zhege "+this.gameObject.transform.parent.gameObject.activeInHierarchy);
  29. // Debug.Log(this.gameObject.transform.parent.transform.parent + " zhege " + this.gameObject.transform.parent.transform.parent.gameObject.activeInHierarchy);
  30. parent = _parent;
  31. this.gameObject.SetActive(true);
  32. }
  33. public virtual void ReDisplay()
  34. {
  35. this.gameObject.SetActive(true);
  36. }
  37. public virtual void GoBackParent()
  38. {
  39. this.Hiding();
  40. if(parent!=null)
  41. {
  42. parent.ReDisplay();
  43. }
  44. }
  45. public virtual void Init()
  46. {
  47. }
  48. public virtual bool OnEscape()
  49. {
  50. if(curUIType==UIType.Normal)
  51. {
  52. if(this.gameObject.activeSelf)
  53. {
  54. GoBackParent();
  55. return true;
  56. }
  57. }
  58. return false;
  59. }
  60. }
  61. }