GuideWindowBase.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine.UI;
  5. using System;
  6. namespace FrameWork.GuideSystem
  7. {
  8. public class GuideWindowBase : UIWindowBase
  9. {
  10. protected List<GameObject> m_effectList = new List<GameObject>();
  11. protected List<RectTransform> m_uiList = new List<RectTransform>();
  12. protected Image m_mask;
  13. protected Text m_TipText;
  14. public RectTransform m_TipTransfrom;
  15. public override void OnOpen()
  16. {
  17. m_mask = GetImage("mask");
  18. m_TipText = GetText("Text_tip");
  19. m_TipTransfrom = GetRectTransform("Tips");
  20. OnOpenUI();
  21. }
  22. protected virtual void OnOpenUI()
  23. {
  24. }
  25. #region 特效相关
  26. public GameObject CreateEffect(string effectName)
  27. {
  28. GameObject po = GameObjectManager.CreateGameObjectByPool(effectName, RectTransform.gameObject);
  29. m_effectList.Add(po);
  30. return po.gameObject;
  31. }
  32. public void CreateEffect(string effectName, string windowName, string itemName, bool isFollow)
  33. {
  34. //UIWindowBase ui = UIManager.GetUI(windowName);
  35. //UIBase item = ui.GetItem(itemName);
  36. }
  37. public void CreateEffect(string effectName, UIBase ui, Vector3 offset, bool isFollow)
  38. {
  39. GameObject effect = CreateEffect(effectName);
  40. effect.transform.SetParent(ui.transform);
  41. effect.transform.localPosition = offset;
  42. if (!isFollow)
  43. {
  44. effect.transform.SetParent(m_uiRoot.transform);
  45. }
  46. }
  47. public void ClearEffect()
  48. {
  49. for (int i = 0; i < m_effectList.Count; i++)
  50. {
  51. GameObjectManager.DestroyGameObjectByPool(m_effectList[i]);
  52. }
  53. m_effectList.Clear();
  54. }
  55. #endregion
  56. #region 指示图标相关
  57. public void ShowGuideUIByItem(string uiName, UIWindowBase ui, string itemName, Vector3 offset, bool isFollow)
  58. {
  59. GameObject aimUI = ui.GetGuideDynamicCreateItem(itemName);
  60. ShowGuideUI(GetRectTransform(uiName), aimUI, offset, isFollow);
  61. }
  62. public void ShowGuideUIByObject(string uiName, UIWindowBase ui, string objName, Vector3 offset, bool isFollow)
  63. {
  64. GameObject aimUI = ui.GetGameObject(objName);
  65. ShowGuideUI(GetRectTransform(uiName), aimUI, offset, isFollow);
  66. }
  67. public void ShowGuideUI(RectTransform guideUI, GameObject aimUI, Vector3 offset, bool isFollow)
  68. {
  69. m_uiList.Add(guideUI);
  70. guideUI.SetParent(aimUI.transform);
  71. guideUI.SetSiblingIndex(0);
  72. guideUI.anchoredPosition3D = offset;
  73. if (!isFollow)
  74. {
  75. guideUI.SetParent(RectTransform);
  76. }
  77. }
  78. public void HideGuideUI(string uiName)
  79. {
  80. GetRectTransform(uiName).SetParent(m_uiRoot.transform);
  81. SetActive(uiName, false);
  82. }
  83. public void HideAllGuideUI()
  84. {
  85. for (int i = 0; i < m_uiList.Count; i++)
  86. {
  87. m_uiList[i].SetParent(m_uiRoot.transform);
  88. m_uiList[i].gameObject.SetActive(false);
  89. }
  90. m_uiList.Clear();
  91. }
  92. #endregion
  93. #region 提示文本相关
  94. public virtual void ShowTips(string content, Vector3 pos)
  95. {
  96. if (content != null)
  97. {
  98. m_TipTransfrom.gameObject.SetActive(true);
  99. m_TipText.text = content;
  100. GetRectTransform("Tips").anchoredPosition3D = pos;
  101. }
  102. else
  103. {
  104. m_TipTransfrom.gameObject.SetActive(false);
  105. }
  106. }
  107. public virtual void ClearTips()
  108. {
  109. m_TipTransfrom.gameObject.SetActive(false);
  110. }
  111. public virtual void SetMaskAlpha(float alpha)
  112. {
  113. if(alpha != 0)
  114. {
  115. if(m_mask.gameObject.activeSelf == false)
  116. {
  117. m_mask.gameObject.SetActive(true);
  118. }
  119. Color col = m_mask.color;
  120. col.a = alpha;
  121. m_mask.color = col;
  122. }
  123. else
  124. {
  125. m_mask.gameObject.SetActive(false);
  126. }
  127. }
  128. #endregion
  129. #region 动画
  130. #endregion
  131. }
  132. }