Main/Core/NetworkPackage/DTCFile/ServerPack/H01_System/DTC0102_tagCDBPlayer.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Main/Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0403_tagPlayerLoginLoadOK.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Main/Manager/StageManager.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Main/Manager/UIManager.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Main/ResModule/ResManager.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Main/System/UIBase/UIBase.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Main/Core/NetworkPackage/DTCFile/ServerPack/H01_System/DTC0102_tagCDBPlayer.cs
@@ -57,6 +57,8 @@ MainRedDot.Instance.Register(); StageManager.Instance.ToGameScene(); //SettingMgr.Instance.SetIsRecordData(PlayerDatas.Instance.baseData.PlayerID.ToString()); } Main/Core/NetworkPackage/DTCFile/ServerPack/H04_Scene/DTC0403_tagPlayerLoginLoadOK.cs
@@ -30,8 +30,6 @@ { //服务端每次切场景都会通知这个封包, 增加首次地图登录成功事件(如果服务端存在多场景切换的情况) playerLoginOkEvent?.Invoke(); StageManager.Instance.ToGameScene(); Main.OnEnterGameScene(); } finishedLogin = true; //if (mapInitOkEvent != null) Main/Manager/StageManager.cs
@@ -77,11 +77,13 @@ AsyncOperation asyncOperation = SceneManager.LoadSceneAsync("Game"); await OnLoading(asyncOperation, GetManagerRequestDataProgress); await OnLoading(asyncOperation, () => (DTC0403_tagPlayerLoginLoadOK.finishedLogin ? .5f : 0f) + GetManagerRequestDataProgress() * .5f); // 加载初始化数据完成 currentStage = StageName.Game; Main.OnEnterGameScene(); AfterLoadingGameScene?.Invoke(); UIManager.Instance.OpenWindow<MainWin>(); Main/Manager/UIManager.cs
@@ -25,9 +25,9 @@ private Transform staticTrans; private Transform bottomTrans; private Transform midTrans; private Transform topTrans; private Transform systemTrans; private Transform loadingTrans; // UI字典,存储所有已加载的UI,键为UI名称,值为UI实例 private Dictionary<string, List<UIBase>> uiDict = new Dictionary<string, List<UIBase>>(); @@ -112,15 +112,15 @@ staticTrans = uiRoot.Find("Static"); bottomTrans = uiRoot.Find("Bottom"); midTrans = uiRoot.Find("Middle"); topTrans = uiRoot.Find("Top"); loadingTrans = uiRoot.Find("Loading"); systemTrans = uiRoot.Find("System"); layerTransformCache.Clear(); layerTransformCache.Add(UILayer.Static, staticTrans); layerTransformCache.Add(UILayer.Bottom, bottomTrans); layerTransformCache.Add(UILayer.Mid, midTrans); layerTransformCache.Add(UILayer.Top, topTrans); layerTransformCache.Add(UILayer.System, systemTrans); layerTransformCache.Add(UILayer.Loading, loadingTrans); } #endregion @@ -142,16 +142,16 @@ result = BASE_SORTING_ORDER; break; case UILayer.Bottom: result = BASE_SORTING_ORDER * 10; break; case UILayer.Mid: result = BASE_SORTING_ORDER * 100; break; case UILayer.Top: case UILayer.Mid: result = BASE_SORTING_ORDER * 1000; break; case UILayer.System: result = BASE_SORTING_ORDER * 10000; break; case UILayer.Loading: result = BASE_SORTING_ORDER * 100000; break; default: result = BASE_SORTING_ORDER * 10; @@ -183,11 +183,11 @@ case UILayer.Mid: result = midTrans; break; case UILayer.Top: result = topTrans; break; case UILayer.System: result = systemTrans; break; case UILayer.Loading: result = loadingTrans; break; default: result = bottomTrans; @@ -585,8 +585,14 @@ UIBase returnValue = null; if (closedUIDict.TryGetValue(uiName, out List<UIBase> closedUIList) && closedUIList.Count > 0) Debug.Log("OpenWindow " + uiName); List<UIBase> closedUIList = new List<UIBase>(); if (closedUIDict.TryGetValue(uiName, out closedUIList) && closedUIList.Count > 0) { Debug.Log("OpenWindow getFromClosedDict " + uiName); returnValue = closedUIList[0] as UIBase; closedUIList.RemoveAt(0); @@ -597,6 +603,7 @@ } else { Debug.Log("OpenWindow getNewLoad " + uiName); returnValue = LoadUIResource(uiName); if (returnValue == null) { @@ -721,7 +728,9 @@ // 获取UI类型名称 string uiName = ui.uiName; Debug.Log("CloseWindow " + uiName + " destroy : " + destroy.ToString()); // 收集所有子UI List<UIBase> childrenUI = new List<UIBase>(); if (ui.supportParentChildRelation) @@ -792,8 +801,10 @@ } closedUIDict[uiName].Add(ui); // 隐藏UI ui.gameObject.SetActive(false); Debug.Log("CloseWindow " + uiName + " destroy : " + destroy.ToString() + " push to closedUIDict"); // 隐藏UI (交给handle close内部自己去做) // ui.gameObject.SetActive(false); } // 更新UI排序顺序 @@ -834,7 +845,7 @@ for (int i = 0; i < allUI.Count; i++) { UIBase uiBase = allUI[i]; if (!uiBase.isMainUI && uiBase.uiLayer != UILayer.System) if (!uiBase.isMainUI && uiBase.uiLayer < UILayer.System) { CloseWindow(uiBase); } @@ -857,6 +868,14 @@ CloseWindow(ui, true); } foreach (var uiList in closedUIDict.Values) { foreach (var ui in uiList) { GameObject.Destroy(ui.gameObject); } } // 清空UI字典和栈 uiDict.Clear(); uiStack.Clear(); Main/ResModule/ResManager.cs
@@ -1,4 +1,4 @@ using UnityEngine; using UnityEngine; using System.Collections; using System.Collections.Generic; using Cysharp.Threading.Tasks; @@ -142,10 +142,11 @@ T asset = null; var path = ($"Assets/ResourcesOut/{directory}/{name}" + GetExtension(typeof(T))).Replace("//", "/").Trim().Replace("\\", "/"); path = System.Text.RegularExpressions.Regex.Replace(path, @"[\p{C}]", ""); if (AssetSource.uiFromEditor) { #if UNITY_EDITOR // TODO YYL 还是要找到字符串问题 path = System.Text.RegularExpressions.Regex.Replace(path, @"[\p{C}]", ""); asset = UnityEditor.AssetDatabase.LoadAssetAtPath<T>(path); #endif } Main/System/UIBase/UIBase.cs
@@ -8,11 +8,12 @@ public enum UILayer { Static, // 静态UI 适合做 常驻用的如 主界面 Bottom, // 最底层 适合做 主界面上面的 一级窗口 一级界面 Mid, // 适合做 二级窗口 二级界面 Top, // 适合做提示弹窗 System // 网络弹窗/其他重要弹窗/系统公告 Static, // 静态UI 适合做 战斗 主界面 Bottom, // 主界面 Mid, // 功能窗口 System, // 网络弹窗/其他重要弹窗 Loading, // 加载界面 } public enum UIAnimationType @@ -46,7 +47,7 @@ // 动画相关 [SerializeField] public UIAnimationType openAnimationType = UIAnimationType.ScaleInOut; [SerializeField] public UIAnimationType closeAnimationType = UIAnimationType.None; [SerializeField][HideInInspector] public float animationDuration = 0.3f; [SerializeField]/*[HideInInspector]*/ public float animeDuration = 0.2f; [SerializeField][HideInInspector] public Ease animationEase = Ease.OutQuad; // 确保使用 DG.Tweening.Ease // 运行时状态 @@ -82,6 +83,8 @@ protected Vector3 originalScale; protected Vector3 originalPosition; protected Sequence currentAnimation; private CanvasScaler canvasScaler; #endregion @@ -180,6 +183,8 @@ { gameObject.AddComponent<UnityEngine.UI.GraphicRaycaster>(); } canvasScaler = GetComponent<CanvasScaler>(); // 获取RectTransform组件 rectTransform = GetComponent<RectTransform>(); @@ -500,11 +505,7 @@ case UIAnimationType.ScaleInOut: if (rectTransform != null) { rectTransform.localScale = Vector3.zero; } if (canvasGroup != null) { canvasGroup.alpha = 0f; canvasScaler.scaleFactor = 0.3f; canvasGroup.interactable = false; canvasGroup.blocksRaycasts = false; } @@ -582,18 +583,14 @@ case UIAnimationType.FadeInOut: if (canvasGroup != null) { currentAnimation.Append(canvasGroup.DOFade(1f, animationDuration).SetEase(animationEase)); currentAnimation.Append(canvasGroup.DOFade(1f, animeDuration).SetEase(animationEase)); } break; case UIAnimationType.ScaleInOut: if (rectTransform != null) { currentAnimation.Append(rectTransform.DOScale(originalScale, animationDuration).SetEase(animationEase)); } if (canvasGroup != null) { currentAnimation.Join(canvasGroup.DOFade(1f, animationDuration).SetEase(animationEase)); currentAnimation.Append(DOVirtual.Float(0.3f, originalScale.x, animeDuration, (value) => {canvasScaler.scaleFactor = value;}).SetEase(animationEase)); } break; @@ -603,11 +600,11 @@ case UIAnimationType.SlideFromRight: if (rectTransform != null) { currentAnimation.Append(rectTransform.DOAnchorPos(originalPosition, animationDuration).SetEase(animationEase)); currentAnimation.Append(rectTransform.DOAnchorPos(originalPosition, animeDuration).SetEase(animationEase)); } if (canvasGroup != null) { currentAnimation.Join(canvasGroup.DOFade(1f, animationDuration).SetEase(animationEase)); currentAnimation.Join(canvasGroup.DOFade(1f, animeDuration).SetEase(animationEase)); } break; } @@ -624,6 +621,8 @@ canvasGroup.blocksRaycasts = true; } }); currentAnimation.Play(); } catch (System.Exception e) { @@ -662,18 +661,14 @@ case UIAnimationType.FadeInOut: if (canvasGroup != null) { currentAnimation.Append(canvasGroup.DOFade(0f, animationDuration).SetEase(animationEase)); currentAnimation.Append(canvasGroup.DOFade(0f, animeDuration).SetEase(animationEase)); } break; case UIAnimationType.ScaleInOut: if (rectTransform != null) { currentAnimation.Append(rectTransform.DOScale(Vector3.zero, animationDuration).SetEase(animationEase)); } if (canvasGroup != null) { currentAnimation.Join(canvasGroup.DOFade(0f, animationDuration).SetEase(animationEase)); currentAnimation.Append(DOVirtual.Float(originalScale.x, 0.3f, animeDuration, (value) => {canvasScaler.scaleFactor = value;}).SetEase(animationEase)); } break; @@ -682,11 +677,11 @@ { Vector2 endPos = originalPosition; endPos.y = Screen.height; currentAnimation.Append(rectTransform.DOAnchorPos(endPos, animationDuration).SetEase(animationEase)); currentAnimation.Append(rectTransform.DOAnchorPos(endPos, animeDuration).SetEase(animationEase)); } if (canvasGroup != null) { currentAnimation.Join(canvasGroup.DOFade(0f, animationDuration).SetEase(animationEase)); currentAnimation.Join(canvasGroup.DOFade(0f, animeDuration).SetEase(animationEase)); } break; @@ -695,11 +690,11 @@ { Vector2 endPos = originalPosition; endPos.y = -Screen.height; currentAnimation.Append(rectTransform.DOAnchorPos(endPos, animationDuration).SetEase(animationEase)); currentAnimation.Append(rectTransform.DOAnchorPos(endPos, animeDuration).SetEase(animationEase)); } if (canvasGroup != null) { currentAnimation.Join(canvasGroup.DOFade(0f, animationDuration).SetEase(animationEase)); currentAnimation.Join(canvasGroup.DOFade(0f, animeDuration).SetEase(animationEase)); } break; @@ -708,11 +703,11 @@ { Vector2 endPos = originalPosition; endPos.x = -Screen.width; currentAnimation.Append(rectTransform.DOAnchorPos(endPos, animationDuration).SetEase(animationEase)); currentAnimation.Append(rectTransform.DOAnchorPos(endPos, animeDuration).SetEase(animationEase)); } if (canvasGroup != null) { currentAnimation.Join(canvasGroup.DOFade(0f, animationDuration).SetEase(animationEase)); currentAnimation.Join(canvasGroup.DOFade(0f, animeDuration).SetEase(animationEase)); } break; @@ -721,11 +716,11 @@ { Vector2 endPos = originalPosition; endPos.x = Screen.width; currentAnimation.Append(rectTransform.DOAnchorPos(endPos, animationDuration).SetEase(animationEase)); currentAnimation.Append(rectTransform.DOAnchorPos(endPos, animeDuration).SetEase(animationEase)); } if (canvasGroup != null) { currentAnimation.Join(canvasGroup.DOFade(0f, animationDuration).SetEase(animationEase)); currentAnimation.Join(canvasGroup.DOFade(0f, animeDuration).SetEase(animationEase)); } break; } @@ -741,6 +736,8 @@ CompleteClose(); } }); currentAnimation.Play(); } catch (System.Exception e) {