BaseUIForms.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /***
  2. *
  3. * Title: "SUIFW" UI框架项目
  4. * 主题:基础UI窗体
  5. * Description:
  6. * 功能:所有用户UI窗体的父类
  7. * 1:定于四个“UI窗体”的状态
  8. * Display: 显示状态
  9. * Hiding: 隐藏状态(即:不能看见,不能操作)
  10. * Redisplay: 重新显示状态
  11. * Freeze: 冻结状态(即:在其他窗体下面,看见但不能操作)
  12. *
  13. * 2:
  14. *
  15. * Date: 2017
  16. * Version: 0.1版本
  17. * Modify Recoder:
  18. *
  19. *
  20. */
  21. using UnityEngine;
  22. using UnityEngine.UI;
  23. using System;
  24. using System.Collections.Generic;
  25. namespace SUIFW
  26. {
  27. public class BaseUIForms : MonoBehaviour
  28. {
  29. /* 字段 */
  30. //当前(基类)窗口的类型
  31. private UIType _CurrentUIType=new UIType();
  32. /* 属性 */
  33. /// <summary>
  34. /// 属性_当前UI窗体类型
  35. /// </summary>
  36. internal UIType CurrentUIType
  37. {
  38. set
  39. {
  40. _CurrentUIType = value;
  41. }
  42. get
  43. {
  44. return _CurrentUIType;
  45. }
  46. }
  47. #region 窗体生命周期
  48. //页面显示
  49. public virtual void Display()
  50. {
  51. this.gameObject.SetActive(true);
  52. if (_CurrentUIType.UIForms_Type == UIFormsType.PopUp)
  53. {
  54. //添加UI遮罩处理
  55. UIMaskMgr.GetInstance().SetMaskWindow(this.gameObject,_CurrentUIType.UIForms_LucencyType);
  56. }
  57. }
  58. //页面隐藏(不在“栈”集合中)
  59. public virtual void Hiding()
  60. {
  61. this.gameObject.SetActive(false);
  62. if (_CurrentUIType.UIForms_Type == UIFormsType.PopUp)
  63. {
  64. //添加UI遮罩处理
  65. UIMaskMgr.GetInstance().CancleMaskWindow();
  66. }
  67. }
  68. //页面重新显示
  69. public virtual void Redisplay()
  70. {
  71. this.gameObject.SetActive(true);
  72. if (_CurrentUIType.UIForms_Type == UIFormsType.PopUp)
  73. {
  74. //添加UI遮罩处理
  75. UIMaskMgr.GetInstance().SetMaskWindow(this.gameObject, _CurrentUIType.UIForms_LucencyType);
  76. }
  77. }
  78. //页面冻结(还在“栈”集合中)
  79. public virtual void Freeze()
  80. {
  81. this.gameObject.SetActive(true);
  82. }
  83. #endregion
  84. #region 给子类封装的方法
  85. /// <summary>
  86. /// 注册按钮对象事件
  87. /// </summary>
  88. /// <param name="strButtonName">(UI预设)需要注册事件的按钮名称</param>
  89. /// <param name="delHandle">([委托类型]按钮的注册方法)</param>
  90. protected void RigisteButtonObjectEvent(string strButtonName, EventTriggerListener.VoidDelegate delHandle)
  91. {
  92. GameObject goNeedRigistButton = UnityHelper.FindTheChild(this.gameObject, strButtonName).gameObject;
  93. EventTriggerListener.Get(goNeedRigistButton).onClick = delHandle;
  94. }
  95. /// <summary>
  96. /// 关闭与返回UI窗体
  97. /// </summary>
  98. protected void CloseOrReturnUIForms()
  99. {
  100. string strUIFomrsName = null;
  101. int intPosition = -1;
  102. strUIFomrsName = GetType().ToString();
  103. intPosition = strUIFomrsName.IndexOf('.');
  104. if (intPosition != -1)
  105. {
  106. strUIFomrsName = strUIFomrsName.Substring(intPosition + 1);
  107. }
  108. UIManager.GetInstance().CloseOrReturnUIForms(strUIFomrsName);
  109. }
  110. /// <summary>
  111. /// 打开UI窗体
  112. /// </summary>
  113. /// <param name="strUIFormsName"></param>
  114. protected void ShowUIForms(string strUIFormsName)
  115. {
  116. UIManager.GetInstance().ShowUIForms(strUIFormsName);
  117. }
  118. /// <summary>
  119. /// 发送消息
  120. /// </summary>
  121. /// <param name="strMsgType">消息大类</param>
  122. /// <param name="strSmallClassType">消息小类</param>
  123. /// <param name="strMsgContent">消息内容</param>
  124. protected void SendMessage(string strMsgType, string strSmallClassType, object objMsgContent)
  125. {
  126. KeyValuesUpdate kv = new KeyValuesUpdate(strSmallClassType, objMsgContent);
  127. MessageCenter.SendMessage(strMsgType, kv);
  128. }
  129. /// <summary>
  130. /// 显示语言信息
  131. /// </summary>
  132. /// <param name="info"></param>
  133. protected string Show(string info)
  134. {
  135. return LauguageMgr.GetInstance().ShowText(info);
  136. }
  137. #endregion
  138. public void ChangeBlue(Image image)
  139. {
  140. Color color = Color.white;
  141. color.r = 111/255f;
  142. color.g = 168/255f;
  143. color.b = 254/255f;
  144. color.a = 255/255f;
  145. image.color = color;
  146. }
  147. public void ChangeRed(Image image)
  148. {
  149. Color color = Color.white;
  150. color.r = 254 / 255f;
  151. color.g = 1 / 255f;
  152. color.b = 7 / 255f;
  153. color.a = 255 / 255f;
  154. image.color = color;
  155. }
  156. }//Class_end
  157. }