فهرست منبع

load资源释放

zhaoyang 3 سال پیش
والد
کامیت
c34a06b044
19فایلهای تغییر یافته به همراه112 افزوده شده و 2 حذف شده
  1. 4 0
      GameClient/Assets/Game/HotUpdate/Views/ClothingFoster/ClothingView.cs
  2. 5 0
      GameClient/Assets/Game/HotUpdate/Views/ClothingShop/ClothingShopView.cs
  3. 5 0
      GameClient/Assets/Game/HotUpdate/Views/ClothingSynthetic/ClothingSyntheticView.cs
  4. 5 0
      GameClient/Assets/Game/HotUpdate/Views/CommonGame/GetSuitItemVIew.cs
  5. 5 0
      GameClient/Assets/Game/HotUpdate/Views/DressUp/DressUpFightView.cs
  6. 5 0
      GameClient/Assets/Game/HotUpdate/Views/DressUp/DressUpView.cs
  7. 6 0
      GameClient/Assets/Game/HotUpdate/Views/DressUp/PhotographView.cs
  8. 6 0
      GameClient/Assets/Game/HotUpdate/Views/FieldGuide/SuitShowView.cs
  9. 5 0
      GameClient/Assets/Game/HotUpdate/Views/Friend/FriendView.cs
  10. 6 0
      GameClient/Assets/Game/HotUpdate/Views/Login/LoginView.cs
  11. 5 0
      GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryDialogView.cs
  12. 6 0
      GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryFightSingleScoreView.cs
  13. 6 0
      GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryFightSingleView.cs
  14. 6 0
      GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryFightTargetScoreView.cs
  15. 6 0
      GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryFightTargetView.cs
  16. 6 0
      GameClient/Assets/Game/HotUpdate/Views/MainStory/StroyFightResultView.cs
  17. 6 0
      GameClient/Assets/Game/HotUpdate/Views/MainUI/MainUIView.cs
  18. 9 2
      GameClient/Assets/Game/Launcher/Xasset/GFGAsset.cs
  19. 10 0
      GameClient/Assets/ThirdParty/Xasset/Runtime/Loadables/Asset.cs

+ 4 - 0
GameClient/Assets/Game/HotUpdate/Views/ClothingFoster/ClothingView.cs

@@ -37,6 +37,10 @@ namespace GFGGame
                 GameObject.Destroy(_sceneObject);
                 _sceneObject = null;
                 _wrapper = null;
+            }
+            if (_scenePrefab != null)
+            {
+                GFGAsset.Release(ResPathUtil.GetPrefabPath("SceneSuitFoster"));
                 _scenePrefab = null;
             }
             SceneController.DestroyObjectFromView(_gameobject1);

+ 5 - 0
GameClient/Assets/Game/HotUpdate/Views/ClothingShop/ClothingShopView.cs

@@ -45,6 +45,11 @@ namespace GFGGame
                 GameObject.Destroy(_sceneObject);
                 _sceneObject = null;
             }
+            if (_scenePrefab != null)
+            {
+                GFGAsset.Release(ResPathUtil.GetPrefabPath("SceneDressUp"));
+                _scenePrefab = null;
+            }
             if (_comSelected != null)
             {
                 _comSelected.RemoveFromParent();

+ 5 - 0
GameClient/Assets/Game/HotUpdate/Views/ClothingSynthetic/ClothingSyntheticView.cs

@@ -62,6 +62,11 @@ namespace GFGGame
                 GameObject.Destroy(_sceneObject);
                 _sceneObject = null;
             }
+            if (_scenePrefab != null)
+            {
+                GFGAsset.Release(ResPathUtil.GetPrefabPath("SceneDressUpSynthetic"));
+                _scenePrefab = null;
+            }
             if (_imgSelected != null)
             {
                 _imgSelected.RemoveFromParent();

+ 5 - 0
GameClient/Assets/Game/HotUpdate/Views/CommonGame/GetSuitItemVIew.cs

@@ -23,6 +23,11 @@ namespace GFGGame
                 GameObject.Destroy(_sceneObject);
                 _sceneObject = null;
             }
+            if (_scenePrefab != null)
+            {
+                GFGAsset.Release(ResPathUtil.GetPrefabPath("SceneDressUp"));
+                _scenePrefab = null;
+            }
             SceneController.DestroyObjectFromView(_gameObject1);
 
             base.Dispose();

+ 5 - 0
GameClient/Assets/Game/HotUpdate/Views/DressUp/DressUpFightView.cs

@@ -37,6 +37,11 @@ namespace GFGGame
                 GameObject.Destroy(_sceneObject);
                 _sceneObject = null;
             }
+            if (_scenePrefab != null)
+            {
+                GFGAsset.Release(ResPathUtil.GetPrefabPath("SceneDressUp"));
+                _scenePrefab = null;
+            }
             // UI_TypeItem.ClearProxy();
             // UI_PartsListItem.ClearProxy();
             base.Dispose();

+ 5 - 0
GameClient/Assets/Game/HotUpdate/Views/DressUp/DressUpView.cs

@@ -38,6 +38,11 @@ namespace GFGGame
                 GameObject.Destroy(_sceneObject);
                 _sceneObject = null;
             }
+            if (_scenePrefab != null)
+            {
+                GFGAsset.Release(ResPathUtil.GetPrefabPath("SceneDressUp"));
+                _scenePrefab = null;
+            }
             UI_TypeItem.ClearProxy();
             base.Dispose();
         }

+ 6 - 0
GameClient/Assets/Game/HotUpdate/Views/DressUp/PhotographView.cs

@@ -583,6 +583,12 @@ namespace GFGGame
                 GameObject.Destroy(_sceneObject);
                 _sceneObject = null;
             }
+            if (_scenePrefab != null)
+            {
+                GFGAsset.Release(ResPathUtil.GetPrefabPath("ScenePhotograph"));
+                _scenePrefab = null;
+            }
+
             base.Dispose();
         }
         private void CheckGuide(object param)

+ 6 - 0
GameClient/Assets/Game/HotUpdate/Views/FieldGuide/SuitShowView.cs

@@ -24,6 +24,12 @@ namespace GFGGame
                 GameObject.Destroy(_sceneObject);
                 _sceneObject = null;
             }
+            if (_scenePrefab != null)
+            {
+                GFGAsset.Release(ResPathUtil.GetPrefabPath("SceneDressUp"));
+                _scenePrefab = null;
+            }
+
             if (_dressUpObjDataCache != null)
             {
                 _dressUpObjDataCache.Dispose();

+ 5 - 0
GameClient/Assets/Game/HotUpdate/Views/Friend/FriendView.cs

@@ -18,6 +18,11 @@ namespace GFGGame
                 GameObject.Destroy(_sceneObject);
                 _sceneObject = null;
             }
+            if (_scenePrefab != null)
+            {
+                GFGAsset.Release(ResPathUtil.GetPrefabPath("SceneFriend"));
+                _scenePrefab = null;
+            }
 
             base.Dispose();
         }

+ 6 - 0
GameClient/Assets/Game/HotUpdate/Views/Login/LoginView.cs

@@ -22,6 +22,12 @@ namespace GFGGame
                 GameObject.Destroy(_sceneObject);
                 _sceneObject = null;
             }
+            if (_scenePrefab != null)
+            {
+                GFGAsset.Release(ResPathUtil.GetPrefabPath("SceneMain"));
+                _scenePrefab = null;
+            }
+
             base.Dispose();
         }
 

+ 5 - 0
GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryDialogView.cs

@@ -45,6 +45,11 @@ namespace GFGGame
                 GameObject.Destroy(_sceneObject);
                 _sceneObject = null;
             }
+            if (_scenePrefab != null)
+            {
+                GFGAsset.Release(ResPathUtil.GetPrefabPath("SceneStoryDialog"));
+                _scenePrefab = null;
+            }
             _wordTextField = null;
             _arrow = null;
             _isShowLetters = false;

+ 6 - 0
GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryFightSingleScoreView.cs

@@ -384,6 +384,12 @@ namespace GFGGame
                 GameObject.Destroy(_sceneObject);
                 _sceneObject = null;
             }
+            if (_scenePrefab != null)
+            {
+                GFGAsset.Release(ResPathUtil.GetPrefabPath("SceneFightSingleScore"));
+                _scenePrefab = null;
+            }
+
             Reset();
             Timers.inst.Remove(CheckGuide);
         }

+ 6 - 0
GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryFightSingleView.cs

@@ -16,6 +16,12 @@ namespace GFGGame
                 GameObject.Destroy(_sceneObject);
                 _sceneObject = null;
             }
+            if (_scenePrefab != null)
+            {
+                GFGAsset.Release(ResPathUtil.GetPrefabPath("SceneFightSingle"));
+                _scenePrefab = null;
+            }
+
             base.Dispose();
         }
 

+ 6 - 0
GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryFightTargetScoreView.cs

@@ -67,6 +67,12 @@ namespace GFGGame
                 GameObject.Destroy(_sceneObject);
                 _sceneObject = null;
             }
+            if (_scenePrefab != null)
+            {
+                GFGAsset.Release(ResPathUtil.GetPrefabPath("SceneFightTargetScore"));
+                _scenePrefab = null;
+            }
+
             SceneController.DestroyObjectFromView(_gameObject0);
             SceneController.DestroyObjectFromView(_gameObject1);
             SceneController.DestroyObjectFromView(_gameObject2);

+ 6 - 0
GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryFightTargetView.cs

@@ -16,6 +16,12 @@ namespace GFGGame
                 GameObject.Destroy(_sceneObject);
                 _sceneObject = null;
             }
+            if (_scenePrefab != null)
+            {
+                GFGAsset.Release(ResPathUtil.GetPrefabPath("SceneFightTarget"));
+                _scenePrefab = null;
+            }
+
             base.Dispose();
         }
 

+ 6 - 0
GameClient/Assets/Game/HotUpdate/Views/MainStory/StroyFightResultView.cs

@@ -38,6 +38,12 @@ namespace GFGGame
                 GameObject.Destroy(_sceneObject);
                 _sceneObject = null;
             }
+            if (_scenePrefab != null)
+            {
+                GFGAsset.Release(ResPathUtil.GetPrefabPath("SceneFightResult"));
+                _scenePrefab = null;
+            }
+
             if (_ui != null)
             {
                 _ui.Dispose();

+ 6 - 0
GameClient/Assets/Game/HotUpdate/Views/MainUI/MainUIView.cs

@@ -59,6 +59,12 @@ namespace GFGGame
                 GameObject.Destroy(_sceneObject);
                 _sceneObject = null;
             }
+            if (_scenePrefab != null)
+            {
+                GFGAsset.Release(ResPathUtil.GetPrefabPath("SceneMain"));
+                _scenePrefab = null;
+            }
+
             base.Dispose();
         }
 

+ 9 - 2
GameClient/Assets/Game/Launcher/Xasset/GFGAsset.cs

@@ -7,7 +7,7 @@ namespace GFGGame
 {
     public class GFGAsset
     {
-        public static T Load<T>(string path) where T:Object
+        public static T Load<T>(string path) where T : Object
         {
             //VEngine.Logger.I($"GFGAsset.Load {path} {Random.Range(0, int.MaxValue)}");
             T t = null;
@@ -22,7 +22,7 @@ namespace GFGGame
             else
             {
                 t = Resources.Load<T>(path);
-            } 
+            }
             return t;
         }
 
@@ -31,6 +31,13 @@ namespace GFGGame
             //VEngine.Logger.I($"GFGAsset.Release {path} {Random.Range(0, int.MaxValue)}");
             if (path.Contains("Asset"))
             {
+                int count = 0;
+                if (Asset.CacheCount.TryGetValue(path, out count))
+                {
+                    count--;
+                }
+                if (count > 0) return;
+
                 Asset asset;
                 if (Asset.Cache.TryGetValue(path, out asset))
                 {

+ 10 - 0
GameClient/Assets/ThirdParty/Xasset/Runtime/Loadables/Asset.cs

@@ -8,6 +8,7 @@ namespace VEngine
     public class Asset : Loadable, IEnumerator
     {
         public static readonly Dictionary<string, Asset> Cache = new Dictionary<string, Asset>();
+        public static readonly Dictionary<string, int> CacheCount = new Dictionary<string, int>();
 
         public static readonly List<Asset> Unused = new List<Asset>();
 
@@ -78,6 +79,15 @@ namespace VEngine
             {
                 item = Versions.CreateAsset(path, type);
                 Cache.Add(path, item);
+
+            }
+            if (CacheCount.ContainsKey(path))
+            {
+                CacheCount[path] = CacheCount[path] + 1;
+            }
+            else
+            {
+                CacheCount.Add(path, 0);
             }
 
             if (completed != null) item.completed += completed;