From 0333a7ba48bb5c5c28d8eaf1d94e5dd6d990534f Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期三, 25 二月 2026 18:08:26 +0800
Subject: [PATCH] 0312 AI优化代码
---
Main/System/Message/RichText.cs | 13 +++++++++++++
Main/System/Message/RichTextMgr.cs | 15 ++++++++++++++-
Main/Manager/StageManager.cs | 19 ++++++++++++++++++-
3 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/Main/Manager/StageManager.cs b/Main/Manager/StageManager.cs
index 9b6e0a1..c5eb8c2 100644
--- a/Main/Manager/StageManager.cs
+++ b/Main/Manager/StageManager.cs
@@ -37,8 +37,15 @@
{
UIManager.Instance.DestroyAllUI();
+ // 娓呯悊涓婁竴鍦烘櫙鐨勮祫婧愶紝闃叉鍐呭瓨娉勬紡
if (AssetSource.isUseAssetBundle)
{
+ AssetBundleUtility.Instance.UnloadAll();
+ // 绛夊緟璧勬簮鍗歌浇瀹屾垚
+ await UniTask.Yield();
+ Resources.UnloadUnusedAssets();
+ await UniTask.DelayFrame(1);
+
AssetBundleUtility.Instance.Sync_LoadAll("maps/Login");
}
@@ -108,7 +115,17 @@
public async UniTaskVoid ToGameScene()
{
UIManager.Instance.DestroyAllUI();
-
+
+ // 娓呯悊涓婁竴鍦烘櫙鐨勮祫婧愶紝闃叉鍐呭瓨娉勬紡
+ if (AssetSource.isUseAssetBundle)
+ {
+ AssetBundleUtility.Instance.UnloadAll();
+ // 绛夊緟璧勬簮鍗歌浇瀹屾垚
+ await UniTask.Yield();
+ Resources.UnloadUnusedAssets();
+ await UniTask.DelayFrame(1);
+ }
+
BeforeLoadingGameScene?.Invoke();
// ResManager.Instance.PrewarmResources();
diff --git a/Main/System/Message/RichText.cs b/Main/System/Message/RichText.cs
index 26b20bd..044c8bc 100644
--- a/Main/System/Message/RichText.cs
+++ b/Main/System/Message/RichText.cs
@@ -654,6 +654,12 @@
#region 鎵ц浜嬩欢
public void OnPointerClick(PointerEventData eventData)
{
+ // 妫�鏌ョ粍浠舵槸鍚﹀凡绂佺敤鎴栭攢姣侊紝閬垮厤绌烘寚閽堣В寮曠敤
+ if (!this.isActiveAndEnabled)
+ {
+ return;
+ }
+
OnClick?.Invoke();
if (HrefClick)
{
@@ -704,6 +710,13 @@
// 瀛楃瀹藉害缂撳瓨锛岄伩鍏嶉噸澶嶈绠楃浉鍚屽瓧绗�
private Dictionary<string, float> charWidthCache = new Dictionary<string, float>();
+ protected override void OnDisable()
+ {
+ base.OnDisable();
+ // 缁勪欢绂佺敤鏃舵竻绌虹紦瀛橈紝闃叉鍐呭瓨娉勬紡
+ charWidthCache.Clear();
+ }
+
private bool IsModifySize(int _index,out int _size)
{
_size = 0;
diff --git a/Main/System/Message/RichTextMgr.cs b/Main/System/Message/RichTextMgr.cs
index 991ffca..eba10fc 100644
--- a/Main/System/Message/RichTextMgr.cs
+++ b/Main/System/Message/RichTextMgr.cs
@@ -153,7 +153,20 @@
public bool ExecuteEvent(RichTextEventEnum type,HrefInfo href)
{
- return m_RichEvents[type].Execute(type,href);
+ if (m_RichEvents == null || !m_RichEvents.ContainsKey(type))
+ {
+ Debug.LogWarning($"RichTextMgr: Event type {type} not registered");
+ return false;
+ }
+
+ var evt = m_RichEvents[type];
+ if (evt == null)
+ {
+ Debug.LogWarning($"RichTextMgr: Event handler for {type} is null");
+ return false;
+ }
+
+ return evt.Execute(type, href);
}
public string GetDisplay(RichTextEventEnum type,Dictionary<string,string> dic)
--
Gitblit v1.8.0