hch
3 天以前 0333a7ba48bb5c5c28d8eaf1d94e5dd6d990534f
0312 AI优化代码
3个文件已修改
47 ■■■■■ 已修改文件
Main/Manager/StageManager.cs 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Message/RichText.cs 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Message/RichTextMgr.cs 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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();
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;
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)