From 3e3f5888d0ededc60061278d13245a2c5089c292 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Fri, 23 Apr 2021 11:42:27 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=99=BD=E7=89=87=E3=80=91=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=B8=80=E4=BA=9Bdebug=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../~Lua/Framework/Manager/SubUIManager.lua | 1 + .../~Lua/Framework/Manager/UIManager.lua | 10 +------- .../~Lua/Modules/Carbon/CarbonTypePanelV2.lua | 4 +-- .../~Lua/Modules/Common/SpriteLoader.lua | 3 +++ .../AssetBundleMgr/AssetBundleLoader.cs | 1 + .../AssetBundleMgr/AssetBundleManager.cs | 17 +++++++++++-- .../ResourcesMgr/ResLoader/EditorResLoader.cs | 12 +++++++-- .../ResLoader/RuntimeResLoader.cs | 25 +++++++++---------- 8 files changed, 45 insertions(+), 28 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Framework/Manager/SubUIManager.lua b/Assets/ManagedResources/~Lua/Framework/Manager/SubUIManager.lua index 969cef2ee8..9d01e888d5 100644 --- a/Assets/ManagedResources/~Lua/Framework/Manager/SubUIManager.lua +++ b/Assets/ManagedResources/~Lua/Framework/Manager/SubUIManager.lua @@ -73,6 +73,7 @@ function this.Close(sub) sub.lspLoader = nil end resMgr:UnLoadAsset(sub.assetName) + LogError("sub UI close: "..sub.assetName) end diff --git a/Assets/ManagedResources/~Lua/Framework/Manager/UIManager.lua b/Assets/ManagedResources/~Lua/Framework/Manager/UIManager.lua index ed9ef8e2ea..09726094f9 100644 --- a/Assets/ManagedResources/~Lua/Framework/Manager/UIManager.lua +++ b/Assets/ManagedResources/~Lua/Framework/Manager/UIManager.lua @@ -679,15 +679,6 @@ function UIManager.DoLanguageCheck(spLoader, gameObject) end end end - else - local imageArr=gameObject:GetComponentsInChildren(typeof(UnityEngine.UI.Image),true); - for i = 0, imageArr.Length-1 do - if imageArr[i].sprite then - local imgStr=imageArr[i].sprite.name - Log("资源名称:"..imgStr) - imageArr[i].sprite = spLoader:LoadSprite(imgStr) - end - end end end @@ -749,6 +740,7 @@ function UIManager.DelayDestroyPanel(panel) end function UIManager.DestroyPanel(panel) + LogError("Panel Destroy: "..panel.uiConfig.assetName) panel:DestroyUI() GameObject.Destroy(panel.gameObject) resMgr:UnLoadAsset(panel.uiConfig.assetName) diff --git a/Assets/ManagedResources/~Lua/Modules/Carbon/CarbonTypePanelV2.lua b/Assets/ManagedResources/~Lua/Modules/Carbon/CarbonTypePanelV2.lua index db4f0e4ec0..58c3c84654 100644 --- a/Assets/ManagedResources/~Lua/Modules/Carbon/CarbonTypePanelV2.lua +++ b/Assets/ManagedResources/~Lua/Modules/Carbon/CarbonTypePanelV2.lua @@ -224,8 +224,8 @@ function CarbonTypePanelV2:OnShow(...) CheckRedPointStatus(data.redPointType) end - Util.GetGameObject(v, "bg/Mask"):SetActive(false) - Util.GetGameObject(v, "bg/Mask (1)"):SetActive(false) + -- Util.GetGameObject(v, "bg/Mask"):SetActive(false) + -- Util.GetGameObject(v, "bg/Mask (1)"):SetActive(false) end carbonType = PlayerManager.carbonType diff --git a/Assets/ManagedResources/~Lua/Modules/Common/SpriteLoader.lua b/Assets/ManagedResources/~Lua/Modules/Common/SpriteLoader.lua index deb2554c39..47b76dfae6 100644 --- a/Assets/ManagedResources/~Lua/Modules/Common/SpriteLoader.lua +++ b/Assets/ManagedResources/~Lua/Modules/Common/SpriteLoader.lua @@ -42,6 +42,9 @@ function SpriteLoader:UnLoadSprite() LogError("SpriteLoader Repeat UnLoad : ".. self.id..", count : "..SpriteLoaderPool[self.id]) end for name, count in pairs(self.SpriteList) do + if name == "shadow_4" then + LogWarn("lua 回收资源:name:"..name..", count:"..count) + end resMgr:UnLoadAsset(name, count) end self.SpriteList = {} diff --git a/Assets/Scripts/Core/ResMgr/AssetBundleMgr/AssetBundleLoader.cs b/Assets/Scripts/Core/ResMgr/AssetBundleMgr/AssetBundleLoader.cs index d9593b7b20..5b275bb86c 100644 --- a/Assets/Scripts/Core/ResMgr/AssetBundleMgr/AssetBundleLoader.cs +++ b/Assets/Scripts/Core/ResMgr/AssetBundleMgr/AssetBundleLoader.cs @@ -280,6 +280,7 @@ namespace ResMgr #endif return t; } + Debug.LogWarning("LoadAB:" + assetName + ", Failed"); return null; } diff --git a/Assets/Scripts/Core/ResMgr/AssetBundleMgr/AssetBundleManager.cs b/Assets/Scripts/Core/ResMgr/AssetBundleMgr/AssetBundleManager.cs index 9c897bfd5b..42f9b86996 100644 --- a/Assets/Scripts/Core/ResMgr/AssetBundleMgr/AssetBundleManager.cs +++ b/Assets/Scripts/Core/ResMgr/AssetBundleMgr/AssetBundleManager.cs @@ -124,7 +124,11 @@ namespace ResMgr loader.LifeTime--; if (loader.LifeTime <= 0) { - if (!unLoadList.Contains(loader)) unLoadList.Add(loader); + if (!unLoadList.Contains(loader)) + { + Log(loader.Path, "AB loader UnLoad, lifeTime over: " + loader.Path); + unLoadList.Add(loader); + } } } } @@ -155,7 +159,13 @@ namespace ResMgr UnLoadAssetBundle(); } } - + private void Log(string path, string con) + { + if (path.Contains("shadow_4")) + { + Debug.LogWarning(con); + } + } /// /// 同步加载AB文件 /// @@ -173,6 +183,7 @@ namespace ResMgr loader = GetLoader(path); if (!string.IsNullOrEmpty(loader.FullPath)) { + Log(path, "Load AB name:" + path); bundleMap.Add(path, loader); string[] dependences = manifest.GetAllDependencies(path); loader.LoadAssetBundle(); @@ -308,6 +319,7 @@ namespace ResMgr if (!loader.IsLoadFinish || loader.IsGlobal) continue; if (loader.IsFree) { loader.LifeTime = 0; + Log(loader.Path, "AB loader UnLoad, UnUsed: " + loader.Path); unLoadList.Add(loader); } } @@ -341,6 +353,7 @@ namespace ResMgr AssetBundleLoader loader = null; if (bundleMap.TryGetValue(path, out loader)) { + Log(loader.Path, "UnLoadAssetBundle: " + path); bundleMap.Remove(path); loader.UnLoad(isForce); loaderPool.CollectOne(loader.gameObject); diff --git a/Assets/Scripts/Core/ResMgr/ResourcesMgr/ResLoader/EditorResLoader.cs b/Assets/Scripts/Core/ResMgr/ResourcesMgr/ResLoader/EditorResLoader.cs index ace5403b13..04b911542b 100644 --- a/Assets/Scripts/Core/ResMgr/ResourcesMgr/ResLoader/EditorResLoader.cs +++ b/Assets/Scripts/Core/ResMgr/ResourcesMgr/ResLoader/EditorResLoader.cs @@ -208,7 +208,11 @@ namespace ResMgr { resData.RefCount--; if (resData.RefCount <= 0) { - resMap.Remove(name); + if (resData.RefCount == 0) + { + Debug.LogWarning("UnLoadAsset:" + name + ", Count:" + resData.RefCount); + } + resMap.Remove(name); resData.UnLoad(); resDataPool.Release(resData); } @@ -224,9 +228,13 @@ namespace ResMgr { if (resMap.TryGetValue(name, out resData)) { resData.RefCount -= count; - //Debug.LogWarning("UnLoadAsset:" + name + ", Count:" + resData.RefCount); + if (resData.RefCount <= 0) { + if(resData.RefCount == 0) + { + Debug.LogWarning("UnLoadAsset:" + name + ", Count:" + resData.RefCount); + } resMap.Remove(name); resData.UnLoad(); resDataPool.Release(resData); diff --git a/Assets/Scripts/Core/ResMgr/ResourcesMgr/ResLoader/RuntimeResLoader.cs b/Assets/Scripts/Core/ResMgr/ResourcesMgr/ResLoader/RuntimeResLoader.cs index b4f327e4ab..4995bba4b9 100644 --- a/Assets/Scripts/Core/ResMgr/ResourcesMgr/ResLoader/RuntimeResLoader.cs +++ b/Assets/Scripts/Core/ResMgr/ResourcesMgr/ResLoader/RuntimeResLoader.cs @@ -171,6 +171,13 @@ namespace ResMgr ab.Unload(true); } + private void Log(string name, string con) + { + if (name.Equals("shadow_4")) + { + Debug.LogWarning(con); + } + } /// /// 加载资源 /// @@ -189,7 +196,7 @@ namespace ResMgr if (resMap.TryGetValue(name, out resData)) { resData.RefCount++; - Debug.Log("LoadAsset add:" + name + ", Count:" + resData.RefCount); + Log(name, "LoadAsset add:" + name + ", Count:" + resData.RefCount); asset = resData.Asset as T; } else @@ -204,7 +211,7 @@ namespace ResMgr resData = resDataPool.Get(); resData.Name = name; resData.RefCount++; - Debug.Log("LoadAsset new:" + name + ", Count:" + resData.RefCount); + Log(name, "LoadAsset new:" + name + ", Count:" + resData.RefCount); resMap.Add(name, resData); asset = loader.LoadAsset(name); resData.LoadSuccess(loader, asset); @@ -338,13 +345,9 @@ namespace ResMgr if (resMap.TryGetValue(name, out resData)) { resData.RefCount--; - //Debug.LogWarning("UnLoadAsset:" + name + ", Count:" + resData.RefCount); + Log(name, "UnLoadAsset:" + name + ", Count:" + resData.RefCount); if (resData.RefCount <= 0) { - if (resData.RefCount == 0) - { - Debug.LogWarning("UnLoadAsset:" + name + ", Count:" + resData.RefCount); - } resMap.Remove(name); resData.UnLoad(); resDataPool.Release(resData); @@ -361,13 +364,9 @@ namespace ResMgr if (resMap.TryGetValue(name, out resData)) { resData.RefCount -= count; - //Debug.LogWarning("UnLoadAsset:" + name + ", Count:" + resData.RefCount); + Log(name, "UnLoadAsset:" + name + ", Count:" + resData.RefCount); if (resData.RefCount <= 0) { - if (resData.RefCount == 0) - { - Debug.LogWarning("UnLoadAsset:" + name + ", Count:" + resData.RefCount); - } resMap.Remove(name); resData.UnLoad(); resDataPool.Release(resData); @@ -389,7 +388,7 @@ namespace ResMgr if (!resData.IsFinish) continue; if (resData.RefCount != 0) continue; - Debug.LogWarning("UnLoadAsset:" + resData.Name + ", unUse"); + Log(resData.Name, "UnLoadAsset:" + resData.Name + ", unUse"); resMap.Remove(resData.Name); resData.UnLoad(); resDataPool.Release(resData);