Main/Manager/UIManager.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Main/System/Main/MainWin.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Main/System/UIBase/OneLevelWin.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Main/System/UIBase/UIBase.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Main/Manager/UIManager.cs
@@ -225,6 +225,26 @@ return null; } public UIBase GetUI(string uiName) { if (string.IsNullOrEmpty(uiName)) { // 记录错误日志 Debug.LogError("UI名称为空"); return null; } // 尝试从字典中获取UI实例列表 if (uiDict.TryGetValue(uiName, out List<UIBase> uiList) && uiList.Count > 0) { // 返回第一个实例 return uiList[0]; } // 如果不存在,返回null return null; } public List<T> GetUIList<T>() where T : UIBase { List<T> uiList = new List<T>(); @@ -583,14 +603,12 @@ return target; } public UIBase OpenWindow(string uiName) public UIBase OpenWindow(string uiName, int functionOrder = 0) { // 优先从closedUIDict中获取 UIBase parentUI = null; UIBase returnValue = null; Debug.Log("OpenWindow " + uiName); List<UIBase> closedUIList = new List<UIBase>(); @@ -664,6 +682,7 @@ UpdateUISortingOrder(); // 打开UI returnValue.functionOrder = functionOrder; returnValue.HandleOpen(); OnOpenWindow?.Invoke(returnValue); @@ -677,11 +696,11 @@ /// <summary> /// 打开UI /// </summary> public T OpenWindow<T>() where T : UIBase public T OpenWindow<T>(int functionOrder = 0) where T : UIBase { // 获取UI类型名称 string uiName = typeof(T).Name; return OpenWindow(uiName) as T; return OpenWindow(uiName, functionOrder) as T; } /// <summary> Main/System/Main/MainWin.cs
@@ -8,10 +8,10 @@ /// </summary> public class MainWin : UIBase { private GameObject windowBackground; public GameObject windowBackground; // 底部按钮组 private Button[] bottomTabButtons; public Button[] bottomTabButtons; private GameObject[] bottomTabEffects; @@ -27,18 +27,6 @@ protected override void InitComponent() { base.InitComponent(); windowBackground = _rectTransform.Find("RawImgBackground").gameObject; bottomTabButtons = new Button[5]; for (int i = 1; i <= 5; i++) { string buttonName = "Buttons/Button" + i; bottomTabButtons[i-1] = _rectTransform.Find(buttonName).GetComponent<Button>(); #if UNITY_EDITOR //测试代码 #endif } // 初始化UI组件事件 InitButtonEvents(); Main/System/UIBase/OneLevelWin.cs
@@ -29,20 +29,29 @@ { base.InitComponent(); m_TitleIcon = this.GetComponent<Image>("Pivot/Container_BackGround/Img_Title"); m_Group = this.GetComponent<FunctionButtonGroup>("Pivot/Container_Functions"); m_Left = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Left"); m_Right = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Right"); m_Close = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Close"); m_Copper = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/SilverCountBG/CountText"); // // 跟原版的差别 Transform trans = transform; // if (_rectTransform != null) // { // trans = _rectTransform; // } m_TitleIcon = trans.GetComponent<Image>("Pivot/Container_BackGround/Img_Title"); m_Group = trans.GetComponent<FunctionButtonGroup>("Pivot/Container_Functions"); m_Left = trans.GetComponent<Button>("Pivot/Container_Buttons/Btn_Left"); m_Right = trans.GetComponent<Button>("Pivot/Container_Buttons/Btn_Right"); m_Close = trans.GetComponent<Button>("Pivot/Container_Buttons/Btn_Close"); m_Copper = trans.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/SilverCountBG/CountText"); if (m_Copper != null) m_Diamond = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldCountBG/CountText"); m_BindDiamond = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldPaperCountBG/CountText"); m_Diamond = trans.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldCountBG/CountText"); m_BindDiamond = trans.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldPaperCountBG/CountText"); m_SubWindowContainer = this.GetComponent<RectTransform>("Pivot/Container_SubWindow"); m_SubWindowContainer = trans.GetComponent<RectTransform>("Pivot/Container_SubWindow"); var name = this.gameObject.name; var name = gameObject.name; var infos = WindowConfig.GetWindowFunctionInfos(name); foreach (var info in infos) { Main/System/UIBase/UIBase.cs
@@ -24,7 +24,9 @@ SlideFromTop, // 从顶部滑入 SlideFromBottom, // 从底部滑入 SlideFromLeft, // 从左侧滑入 SlideFromRight // 从右侧滑入 SlideFromRight, // 从右侧滑入 ScaleOverInOut,// 缩放(超过)之后再返回 } [RequireComponent(typeof(Canvas))] @@ -47,6 +49,8 @@ // 动画相关 [SerializeField] public UIAnimationType openAnimationType = UIAnimationType.None; [SerializeField] public UIAnimationType closeAnimationType = UIAnimationType.None; [SerializeField] protected RectTransform _rectTransform; //界面默认添加根节点用于表现界面开启关闭动画 [SerializeField]/*[HideInInspector]*/ public float animeDuration = 0.2f; [SerializeField][HideInInspector] public Ease animationEase = Ease.OutQuad; // 确保使用 DG.Tweening.Ease @@ -69,7 +73,13 @@ private Button btnClickEmptyClose; protected int functionOrder = 0; // 跟OneLevelWin联动 实际上是需要继承自OneLevelWin才能生效的值 使用需要注意 int m_FunctionOrder = 0; public int functionOrder { get { return m_FunctionOrder; } set { m_FunctionOrder = value; } } // 内部状态 protected bool isActive = false; @@ -79,7 +89,6 @@ // 组件引用 protected Canvas canvas; protected CanvasGroup canvasGroup; protected RectTransform _rectTransform; //界面默认添加根节点用于表现界面开启关闭动画 // 动画相关 protected Vector3 originalPosition; @@ -93,7 +102,6 @@ protected virtual void Awake() { CreateRootNode(); // 防止有人不写base.InitComponent引发错误 所以拆分 InitComponentInternal(); // 在Awake中进行基本初始化 @@ -113,35 +121,6 @@ screenMask.transform.localScale = Vector3.one; screenMask.transform.localPosition = Vector3.zero; screenMask.transform.SetAsFirstSibling(); } } private void CreateRootNode() { if (openAnimationType == UIAnimationType.None && closeAnimationType == UIAnimationType.None) return; List<Transform> children = new List<Transform>(); foreach (Transform child in transform) { children.Add(child); } rootNode = new GameObject("WindowRoot"); rootNode.transform.SetParent(transform, false); rootNode.layer = LayerMask.NameToLayer("UI"); _rectTransform = rootNode.AddMissingComponent<RectTransform>(); //设置成拉伸效果,和父容器保持同样大小自动适配 _rectTransform.anchorMin = Vector2.zero; _rectTransform.anchorMax = Vector2.one; _rectTransform.pivot = new Vector2(0.5f, 0.5f); _rectTransform.anchoredPosition = Vector2.zero; _rectTransform.sizeDelta = Vector2.zero; // 设置为0,表示拉伸到父容器大小 foreach (Transform child in children) { child.SetParent(rootNode.transform, false); } } @@ -259,6 +238,13 @@ PlayOpenAnimation(); OnOpen(); ExecuteNextFrame(NextFrameAfterOpen); } protected virtual void NextFrameAfterOpen() { } // 关闭UI - 修改后的方法 @@ -279,7 +265,6 @@ // 禁用交互但保持可见 if (canvasGroup != null) { canvasGroup.interactable = false; canvasGroup.blocksRaycasts = false; } @@ -528,7 +513,6 @@ if (canvasGroup != null) { canvasGroup.alpha = 0f; canvasGroup.interactable = false; canvasGroup.blocksRaycasts = false; } if (canvasScaler != null) @@ -541,7 +525,6 @@ if (canvasGroup != null) { canvasGroup.alpha = 1f; canvasGroup.interactable = false; canvasGroup.blocksRaycasts = false; } if (canvasScaler != null) @@ -634,11 +617,12 @@ // 启用交互 if (canvasGroup != null) { canvasGroup.interactable = true; canvasGroup.blocksRaycasts = true; } }); // currentAnimation.ingoreTimeScale = true; currentAnimation.Play(); } @@ -650,7 +634,6 @@ if (canvasGroup != null) { canvasGroup.alpha = 1f; canvasGroup.interactable = true; canvasGroup.blocksRaycasts = true; } isAnimating = false; @@ -667,7 +650,6 @@ if (canvasGroup != null) { canvasGroup.alpha = 1f; canvasGroup.interactable = true; canvasGroup.blocksRaycasts = true; } if (canvasScaler != null)