少年修仙传客户端代码仓库
hch
2024-12-02 e471ff18d7f8276765cef1ea0906f667b0548355
0312 修复聊天浮窗 真机报错问题
2个文件已修改
86 ■■■■ 已修改文件
System/Chat/ChatFloatWin.cs 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/WindowBase/WindowCenter.cs 50 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatFloatWin.cs
@@ -15,11 +15,8 @@
    {
        [SerializeField] RectTransform m_ContainerFloat;
        [SerializeField] RichText m_Chat;
        [SerializeField] CanvasGroup canvasGroup;
        DateTime overdueTime = DateTime.Now;
        Coroutine cacheCoroutine;
        DateTime overdueTime;
        ChatCenter chatCenter
        {
@@ -42,21 +39,19 @@
        protected override void OnPreOpen()
        {
            m_ContainerFloat.SetActive(false);
            ChatCtrl.Inst.chatFloatUpdate += ChatFloatUpdate;
            WindowCenter.Instance.windowAfterOpenEvent += WindowAfterOpenEvent;
        }
        protected override void OnAfterOpen()
        {
            ChatCtrl.Inst.chatFloatUpdate += ChatFloatUpdate;
        }
        protected override void OnPreClose()
        {
            ChatCtrl.Inst.chatFloatUpdate -= ChatFloatUpdate;
            if (cacheCoroutine != null)
            {
                StopCoroutine(cacheCoroutine);
                cacheCoroutine = null;
            }
            WindowCenter.Instance.windowAfterOpenEvent -= WindowAfterOpenEvent;
        }
        protected override void OnAfterClose()
@@ -73,6 +68,14 @@
            }
        }
        void WindowAfterOpenEvent(Window window)
        {
            if (window is MainInterfaceWin || window is LoadingWin || window is TreasureBaseWin)
            {
                m_ContainerFloat.SetActive(false);
            }
        }
        private void ChatFloatUpdate(ChatData data)
        {
            if (!chatCenter.IsShowChatFloat())
@@ -80,11 +83,7 @@
                return;
            }
            if (cacheCoroutine != null)
            {
                StopCoroutine(cacheCoroutine);
                cacheCoroutine = null;
            }
            if (data == null)
            {
                return;
@@ -103,21 +102,18 @@
                    return;
            }
            m_ContainerFloat.SetActive(true);
            canvasGroup.alpha = 0;
            m_Chat.text = string.Empty;
            overdueTime = DateTime.Now.AddTicks(3 * TimeSpan.TicksPerSecond);
            if (data.infoList != null)
            {
                m_Chat.SetExtenalData(data.infoList);
            }
            cacheCoroutine = StartCoroutine(Co_SetText(StringUtility.Contact(SetChatExtraInfo(data), data.content)));
            Co_SetText(StringUtility.Contact(SetChatExtraInfo(data), data.content));
        }
        IEnumerator Co_SetText(string value)
        void Co_SetText(string value)
        {
            yield return null;
            m_Chat.text = value;
            canvasGroup.alpha = 1;
            if (m_Chat.preferredWidth >= 1000)
            {
                m_Chat.alignment = TextAnchor.MiddleLeft;
System/WindowBase/WindowCenter.cs
@@ -504,6 +504,7 @@
        internal void NotifyAfterOpen<T>(T window) where T : Window
        {
            CalcMainInterfaceWin();
            if (windowAfterOpenEvent != null)
            {
                windowAfterOpenEvent(window);
@@ -528,6 +529,7 @@
        internal void JumpNotifyAfterClose<T>(T window) where T : Window
        {
            CalcMainInterfaceWin();
            if (jumpWindowCloseEvent != null)
            {
                jumpWindowCloseEvent(window);
@@ -579,7 +581,6 @@
        float checkTimer = 0f;
        private void LateUpdate()
        {
            var checkMainWinImmedidately = closeCommands.Count + openCommands.Count > 0;
            while (closeCommands.Count > 0)
            {
                var command = closeCommands[0];
@@ -621,39 +622,38 @@
                }
            }
        }
            checkTimer += checkMainWinImmedidately ? 1f : Time.deltaTime;
            if (checkTimer > 0.5f)
        //主界面的开关默认处理
        void CalcMainInterfaceWin()
        {
            if (!StageLoad.Instance.isLoading)
            {
                checkTimer = 0f;
                if (!StageLoad.Instance.isLoading)
                {
                    var exceptOpen = StageLoad.Instance.stageType == Stage.E_StageType.Dungeon
                        && !ExistAnyFullScreenOrMaskWinLEqual(WindowType.Base)
                        && !IsOpen("DefaultDialogueBoxWin")
                        && !IsOpen("DialogueDuidanceWin")
                        && !IsOpen("TaskBoxBGMWin")
                        && !IsOpen("WelcomeWin")
                        && !IsOpen("HazyRegionDialogueWin")
                        && !IsOpen("NormalDialogueWin")
                        && !IsOpen("GuideDialogueWin");
                var exceptOpen = StageLoad.Instance.stageType == Stage.E_StageType.Dungeon
                    && !ExistAnyFullScreenOrMaskWinLEqual(WindowType.Base)
                    && !IsOpen("DefaultDialogueBoxWin")
                    && !IsOpen("DialogueDuidanceWin")
                    && !IsOpen("TaskBoxBGMWin")
                    && !IsOpen("WelcomeWin")
                    && !IsOpen("HazyRegionDialogueWin")
                    && !IsOpen("NormalDialogueWin")
                    && !IsOpen("GuideDialogueWin");
                    if (exceptOpen != IsOpen("MainInterfaceWin") && windows.ContainsKey("MainInterfaceWin"))
                if (exceptOpen != IsOpen("MainInterfaceWin") && windows.ContainsKey("MainInterfaceWin"))
                {
                    if (exceptOpen)
                    {
                        if (exceptOpen)
                        {
                            windows["MainInterfaceWin"].Open();
                        }
                        else
                        {
                            windows["MainInterfaceWin"].CloseImmediately();
                        }
                        windows["MainInterfaceWin"].Open();
                    }
                    else
                    {
                        windows["MainInterfaceWin"].CloseImmediately();
                    }
                }
            }
        }
        private void ExecuteFirstOpen(OpenCommand command)
        {
            GetWindowPrefab(command, (bool ok, GameObject prefab) =>