فهرست منبع

预制体、字体加载管理

guodong 1 سال پیش
والد
کامیت
2be5cabe83
31فایلهای تغییر یافته به همراه210 افزوده شده و 161 حذف شده
  1. 5 2
      GameClient/Assets/Game/HotUpdate/Controller/GameController.cs
  2. 1 1
      GameClient/Assets/Game/HotUpdate/DressUp/DressUpObjUI.cs
  3. 31 25
      GameClient/Assets/Game/HotUpdate/DressUp/DressUpUtil.cs
  4. 7 2
      GameClient/Assets/Game/HotUpdate/Effect/EffectUI.cs
  5. 8 0
      GameClient/Assets/Game/HotUpdate/Font.meta
  6. 38 0
      GameClient/Assets/Game/HotUpdate/Font/FontManager.cs
  7. 1 1
      GameClient/Assets/Game/HotUpdate/Font/FontManager.cs.meta
  8. 2 1
      GameClient/Assets/Game/HotUpdate/Game.HotUpdate.asmdef
  9. 5 0
      GameClient/Assets/Game/HotUpdate/HotUpdateEntry.cs
  10. 1 1
      GameClient/Assets/Game/HotUpdate/Views/Arena/ArenaDressInfoView.cs
  11. 1 1
      GameClient/Assets/Game/HotUpdate/Views/Arena/ArenaView.cs
  12. 1 1
      GameClient/Assets/Game/HotUpdate/Views/DressUp/ArenaDressUpFightView.cs
  13. 1 1
      GameClient/Assets/Game/HotUpdate/Views/DressUp/DressUpFightView.cs
  14. 1 1
      GameClient/Assets/Game/HotUpdate/Views/DressUp/DressUpView.cs
  15. 1 1
      GameClient/Assets/Game/HotUpdate/Views/DressUp/PhotographView.cs
  16. 1 1
      GameClient/Assets/Game/HotUpdate/Views/Friend/FriendView.cs
  17. 1 1
      GameClient/Assets/Game/HotUpdate/Views/Login/LoginView.cs
  18. 1 1
      GameClient/Assets/Game/HotUpdate/Views/MainStory/ArenaFightResultView.cs
  19. 1 1
      GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryDialogView.cs
  20. 1 1
      GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryFightSingleScoreView.cs
  21. 1 1
      GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryFightSingleView.cs
  22. 1 1
      GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryFightTargetScoreView.cs
  23. 1 1
      GameClient/Assets/Game/HotUpdate/Views/MainStory/StoryFightTargetView.cs
  24. 1 1
      GameClient/Assets/Game/HotUpdate/Views/MainStory/StroyFightResultView.cs
  25. 1 1
      GameClient/Assets/Game/HotUpdate/Views/MainUI/MainUIView.cs
  26. 2 19
      GameClient/Assets/Game/HotUpdate/Views/ViewManager.cs
  27. 30 10
      GameClient/Assets/Game/Launcher/GFGAsset/AssetReleaser.cs
  28. 0 52
      GameClient/Assets/Game/Launcher/GFGAsset/GFGAsset.cs
  29. 0 32
      GameClient/Assets/Game/Launcher/GFGAsset/GFGSpawner.cs
  30. 64 0
      GameClient/Assets/Game/Launcher/GFGAsset/PrefabManager.cs
  31. 0 0
      GameClient/Assets/Game/Launcher/GFGAsset/PrefabManager.cs.meta

+ 5 - 2
GameClient/Assets/Game/HotUpdate/Controller/GameController.cs

@@ -2,8 +2,7 @@ using FairyGUI;
 using UnityEngine;
 using ET;
 using static GFGGame.LauncherConfig;
-using System.Collections;
-using System.Collections.Generic;
+using GFGGame.Launcher;
 
 namespace GFGGame
 {
@@ -12,6 +11,10 @@ namespace GFGGame
 
         public static void Start()
         {
+            //字体
+            FontLoader.Instance.Init();
+            //GameObject对象池
+            PrefabManager.Instance.Init();
             //界面
             ViewManager.Init();
             //日志

+ 1 - 1
GameClient/Assets/Game/HotUpdate/DressUp/DressUpObjUI.cs

@@ -21,7 +21,7 @@ namespace GFGGame
 
         public void ResetSceneObj(int scale = 100, bool needSetMask = false, bool showSceneType = true, GameObject roleObj = null, bool showBg = true)
         {
-            sceneObject = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath(this.prefabName));
+            sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath(this.prefabName));
             sceneObject.transform.localScale = new Vector3(scale, scale, scale);
             dressUpObj.setSceneObj(sceneObject, needSetMask, showSceneType, roleObj, showBg);
         }

+ 31 - 25
GameClient/Assets/Game/HotUpdate/DressUp/DressUpUtil.cs

@@ -209,12 +209,12 @@ namespace GFGGame
 
         public static void AddAssetReleaser(GameObject gameObj, string resPath, AssetOperationHandle handle)
         {
-            var assetDisposer = gameObj.GetComponent<AssetReleaser>();
-            if (assetDisposer == null)
+            var assetReleaser = gameObj.GetComponent<AssetReleaser>();
+            if (assetReleaser == null)
             {
-                assetDisposer = gameObj.AddComponent<AssetReleaser>();
+                assetReleaser = gameObj.AddComponent<AssetReleaser>();
             }
-            assetDisposer.SetRes(resPath, handle);
+            assetReleaser.SetRes(resPath, handle);
         }
 
         private static void updateLayerRes(ItemCfg itemCfg, GameObject parentObj, int layerId, bool needSetMask, bool showAni = true)
@@ -262,22 +262,29 @@ namespace GFGGame
                     {
                         if (parentObj != null && parentObj.transform != null)
                         {
-                            Transform tf = parentObj.transform.Find(spritObjName);
-                            if (tf != null && tf.gameObject != null && tf.gameObject.activeInHierarchy)
+                            string resPath = ResPathUtil.GetDressUpPath(itemCfg, layerId);
+                            spriteObj = GetGameObjExisted(parentObj, spritObjName, resPath);
+                            if(spriteObj != null)
                             {
-                                var assetDisposer = tf.gameObject.GetComponent<AssetReleaser>();
-                                if (assetDisposer != null)
-                                {
-                                    if (!string.IsNullOrEmpty(assetDisposer.resPath))
-                                    {
-                                        string resPath = ResPathUtil.GetDressUpPath(itemCfg, layerId);
-                                        if (assetDisposer.resPath == resPath)
-                                        {
-                                            TryRemoveObj(parentObj, spritObjName);
-                                        }
-                                    }
-                                }
+                                PrefabManager.Instance.Restore(spriteObj);
                             }
+
+                            //Transform tf = parentObj.transform.Find(spritObjName);
+                            //if (tf != null && tf.gameObject != null && tf.gameObject.activeInHierarchy)
+                            //{
+                            //    var assetDisposer = tf.gameObject.GetComponent<AssetReleaser>();
+                            //    if (assetDisposer != null)
+                            //    {
+                            //        if (!string.IsNullOrEmpty(assetDisposer.resPath))
+                            //        {
+                            //            string resPath = ResPathUtil.GetDressUpPath(itemCfg, layerId);
+                            //            if (assetDisposer.resPath == resPath)
+                            //            {
+                            //                TryRemoveObj(parentObj, spritObjName);
+                            //            }
+                            //        }
+                            //    }
+                            //}
                         }
                     };
                     Timers.inst.Add(0.03f, 1, dressUpPart.OnTimer);
@@ -353,7 +360,7 @@ namespace GFGGame
             {
                 return gameObj;
             }
-            gameObj = CreateAnimationObj(resPath);
+            gameObj = CreateObj(resPath);
             if(gameObj == null)
             {
                 return null;
@@ -391,7 +398,7 @@ namespace GFGGame
             {
                 return gameObj;
             }
-            gameObj = CreateAnimationObj(resPath);
+            gameObj = CreateObj(resPath);
             if (gameObj == null)
             {
                 return null;
@@ -419,7 +426,7 @@ namespace GFGGame
                 GameObject gameObj = transform.gameObject;
                 if (gameObj != null)
                 {
-                    GameObject.DestroyImmediate(gameObj);
+                    PrefabManager.Instance.Restore(gameObj);
                     return true;
                 }
             }
@@ -441,9 +448,8 @@ namespace GFGGame
                     var assetReleaser = gameObj.GetComponent<AssetReleaser>();
                     if (assetReleaser != null)
                     {
-                        if (assetReleaser.resPath == resPath)
+                        if (assetReleaser.ResPath == resPath)
                         {
-
                             return gameObj;
                         }
                     }
@@ -452,7 +458,7 @@ namespace GFGGame
             return null;
         }
 
-        public static GameObject CreateAnimationObj(string resPath)
+        public static GameObject CreateObj(string resPath)
         {
             if (!YooAssets.CheckDressUpResExist(resPath))
             {
@@ -460,7 +466,7 @@ namespace GFGGame
             }
             //var handle = YooAssets.LoadAssetSync<Sprite>(resPath);
             //Sprite sp = handle.AssetObject as Sprite;
-            var gameObj = GFGAsset.Load<GameObject>(resPath);
+            var gameObj = PrefabManager.Instance.SpawnSync(resPath);
             //AddAssetReleaser(gameObj, resPath);
             return gameObj;
         }

+ 7 - 2
GameClient/Assets/Game/HotUpdate/Effect/EffectUI.cs

@@ -24,7 +24,7 @@ namespace GFGGame
                     resPath = ResPathUtil.GetViewEffectPath(uiName, resName);
                     break;
             }
-            _gameObject = DressUpUtil.CreateAnimationObj(resPath);
+            _gameObject = DressUpUtil.CreateObj(resPath);
             if(_gameObject == null)
             {
                 return;
@@ -40,11 +40,16 @@ namespace GFGGame
             isDisposed = true;
             if (_gameObject != null)
             {
-                GameObject.DestroyImmediate(_gameObject);
+                PrefabManager.Instance.Restore(_gameObject);
+                //GameObject.DestroyImmediate(_gameObject);
                 _gameObject = null;
             }
             if (_wrapper != null)
             {
+                if(_wrapper.wrapTarget != null)
+                {
+                    _wrapper.wrapTarget = null;
+                }
                 _wrapper.Dispose();
             }
         }

+ 8 - 0
GameClient/Assets/Game/HotUpdate/Font.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: dfd04369cd823c54cb7102cf839ece93
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 38 - 0
GameClient/Assets/Game/HotUpdate/Font/FontManager.cs

@@ -0,0 +1,38 @@
+using FairyGUI;
+using UnityEngine;
+using YooAsset;
+
+namespace GFGGame
+{
+    public class FontLoader : SingletonBase<FontLoader>
+    {
+        public void Init()
+        {
+
+            Font font0 = LoadFont(ResPathUtil.GetFontPath("FangZhengHeiTiJianTi-1", "ttf"));
+            FontManager.RegisterFont(new DynamicFont("FangZhengHeiTiJianTi-1", font0));
+            Font font1 = LoadFont(ResPathUtil.GetFontPath("FZKTJW--GB1-0", "ttf"));
+            FontManager.RegisterFont(new DynamicFont("FZKTJW--GB1-0", font1));
+            Font font2 = LoadFont(ResPathUtil.GetFontPath("SourceHanSerifCN-Regular-1", "otf"));
+            FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-Regular-1", font2));
+            Font font3 = LoadFont(ResPathUtil.GetFontPath("SourceHanSerifCN-Bold-2", "otf"));
+            FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-Bold-2", font3));
+            Font font4 = LoadFont(ResPathUtil.GetFontPath("SourceHanSerifCN-ExtraLight-3", "otf"));
+            FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-ExtraLight-3", font4));
+            Font font5 = LoadFont(ResPathUtil.GetFontPath("SourceHanSerifCN-Heavy-4", "otf"));
+            FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-Heavy-4", font5));
+            Font font6 = LoadFont(ResPathUtil.GetFontPath("SourceHanSerifCN-Light-5", "otf"));
+            FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-Light-5", font6));
+            Font font7 = LoadFont(ResPathUtil.GetFontPath("SourceHanSerifCN-Medium-6", "otf"));
+            FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-Medium-6", font7));
+            Font font8 = LoadFont(ResPathUtil.GetFontPath("SourceHanSerifCN-SemiBold-7", "otf"));
+            FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-SemiBold-7", font8));
+        }
+
+        private Font LoadFont(string resPath)
+        {
+            AssetOperationHandle handle = YooAssets.LoadAssetSync<Font>(resPath);
+            return handle.AssetObject as Font;
+        }
+    }
+}

+ 1 - 1
GameClient/Assets/Game/Launcher/GFGAsset/GFGAsset.cs.meta → GameClient/Assets/Game/HotUpdate/Font/FontManager.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: a710605ae020793468d3dd1cfb9c97a8
+guid: bf84cd984640f5f4da3a19edeaaff3d7
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 2 - 1
GameClient/Assets/Game/HotUpdate/Game.HotUpdate.asmdef

@@ -4,7 +4,8 @@
     "references": [
         "GUID:065d51621aad9d6498c45bc251a1d8e4",
         "GUID:7a41fac89c3ce014e99efb3723e6a98e",
-        "GUID:e34a5702dd353724aa315fb8011f08c3"
+        "GUID:e34a5702dd353724aa315fb8011f08c3",
+        "GUID:b0a84d582f6a6fa4185f67ce934d99c2"
     ],
     "includePlatforms": [],
     "excludePlatforms": [],

+ 5 - 0
GameClient/Assets/Game/HotUpdate/HotUpdateEntry.cs

@@ -2,7 +2,9 @@
 using ET;
 using System;
 using System.Threading;
+using UniFramework.Pooling;
 using UnityEngine;
+
 namespace GFGGame.HotUpdate
 {
     public class HotUpdateEntry
@@ -10,6 +12,9 @@ namespace GFGGame.HotUpdate
 
         public static void Start()
         {
+            //UniFramework
+            // 初始化对象池系统
+            UniPooling.Initalize();
             //Reporter
             Reporter reporter = GameObject.Find("Reporter").GetComponent<Reporter>();
             reporter.numOfCircleToShow = 10;

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Views/Arena/ArenaDressInfoView.cs

@@ -80,7 +80,7 @@ namespace GFGGame
             _ui.m_c2.selectedIndex = _themeIndex;
             if (_sceneObject == null)
             {
-                _sceneObject = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneArenaDressUp"));
+                _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneArenaDressUp"));
                 MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false);
             }
 

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Views/Arena/ArenaView.cs

@@ -109,7 +109,7 @@ namespace GFGGame
 
             if (_sceneObject == null)
             {
-                _sceneObject = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneArena"));
+                _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneArena"));
             }
 
             UpdateNormal();

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Views/DressUp/ArenaDressUpFightView.cs

@@ -142,7 +142,7 @@ namespace GFGGame
             this.showListType1();
             if (_sceneObject == null)
             {
-                _sceneObject = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneArenaDressUpFight"));
+                _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneArenaDressUpFight"));
                 MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false);
 
                 // GameObject copyObj = _sceneObject.transform.Find("CopyRole").gameObject;

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

@@ -229,7 +229,7 @@ namespace GFGGame
             this.showListType1();
             if (_sceneObject == null)
             {
-                _sceneObject = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneDressUpFight"));
+                _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneDressUpFight"));
                 MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false);
                 MyDressUpHelper.dressUpObj.PutOnDefaultDressUpData(IsTeaPart);
             }

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

@@ -154,7 +154,7 @@ namespace GFGGame
 
             if (_sceneObject == null)
             {
-                _sceneObject = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneDressUp"));
+                _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneDressUp"));
             }
             MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject);
 

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

@@ -122,7 +122,7 @@ namespace GFGGame
             _itemGameObjs = PhotographDataManager.Instance.itemGameObjs;
             if (_sceneObject == null)
             {
-                _sceneObject = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("ScenePhotograph"));
+                _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("ScenePhotograph"));
             }
             PhotographSceneManager.Instance.sceneObject = _sceneObject;
             pinchGesture = new PinchGesture(_ui.target);

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

@@ -70,7 +70,7 @@ namespace GFGGame
             if (_sceneObject == null)
             {
                 CustomSuitData customSuit = CustomSuitDataManager.GetSuitList(CustomSuitDataManager.currentIndex);
-                _sceneObject = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneFriend"));
+                _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneFriend"));
                 _dressUpObj.setSceneObj(_sceneObject);
                 _dressUpObj.AddOrRemove(customSuit.dressUpData.bgId, true);
             }

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

@@ -69,7 +69,7 @@ namespace GFGGame
             MusicManager.Instance.PlayCroutine(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
             if (_sceneObject == null)
             {
-                _sceneObject = GFGAsset.Load<GameObject>(ResPathUtil.GetLoginResPath("LoginSkin1/SceneLogin"));
+                _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetLoginResPath("LoginSkin1/SceneLogin"));
             }
             // SceneController.UpdateLoginScene(_sceneObject);
             ServerInfosComponent serverInfosComponent = GameGlobal.zoneScene.GetComponent<ServerInfosComponent>();

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Views/MainStory/ArenaFightResultView.cs

@@ -83,7 +83,7 @@ namespace GFGGame
             FightData roleData = ArenaDataManager.Instance.DressupList[ArenaDataManager.Instance.CurFightIndex];
             if (_sceneObject == null)
             {
-                _sceneObject = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneFightResult"));
+                _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneFightResult"));
                 MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false, null, false);
             }
             MyDressUpHelper.dressUpObj.PutOnItemList(roleData.itemList);

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

@@ -104,7 +104,7 @@ namespace GFGGame
             base.OnShown();
             if (_sceneObject == null)
             {
-                _sceneObject = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneStoryDialog"));
+                _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneStoryDialog"));
             }
             if (_dressUpObjUI == null)
             {

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

@@ -154,7 +154,7 @@ namespace GFGGame
             roleData = InstanceZonesDataManager.roleData;
             if (_sceneObject == null)
             {
-                _sceneObject = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneFightSingleScore"));
+                _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneFightSingleScore"));
                 MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false, null, false);
             }
             MyDressUpHelper.dressUpObj.PutOnItemList(roleData.itemList);

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

@@ -43,7 +43,7 @@ namespace GFGGame
             base.OnShown();
             if (_sceneObject == null)
             {
-                _sceneObject = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneFightSingle"));
+                _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneFightSingle"));
             }
             MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject);
             StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);

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

@@ -158,7 +158,7 @@ namespace GFGGame
 
             if (_sceneObject == null)
             {
-                _sceneObject = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneFightSingleScore"));
+                _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneFightSingleScore"));
                 MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false, null, false);
             }
             MyDressUpHelper.dressUpObj.PutOnItemList(roleData.itemList);

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

@@ -59,7 +59,7 @@ namespace GFGGame
 
             if (_sceneObject == null)
             {
-                _sceneObject = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneFightTarget"));
+                _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneFightTarget"));
                 _sceneTargetObj = _sceneObject.transform.Find("targetRole").gameObject;
                 _sceneNpcObj = _sceneObject.transform.Find("Npc").gameObject;
 

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

@@ -108,7 +108,7 @@ namespace GFGGame
             FightData roleData = InstanceZonesDataManager.roleData;
             if (_sceneObject == null)
             {
-                _sceneObject = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneFightResult"));
+                _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneFightResult"));
                 MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false, null, false);
             }
             MyDressUpHelper.dressUpObj.PutOnItemList(roleData.itemList);

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

@@ -196,7 +196,7 @@ namespace GFGGame
             _ui.m_headBar.m_txtName.text = RoleDataManager.roleName;
             if (_sceneObject == null)
             {
-                _sceneObject = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneMain"));
+                _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneMain"));
             }
             CheckFunOpen();
             UpdateRedDot();

+ 2 - 19
GameClient/Assets/Game/HotUpdate/Views/ViewManager.cs

@@ -4,6 +4,7 @@ using System;
 using FairyGUI;
 using System.Linq;
 using ET;
+using YooAsset;
 
 namespace GFGGame
 {
@@ -29,25 +30,6 @@ namespace GFGGame
             GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("Common"));
             UIConfig.buttonSound = (NAudioClip)UIPackage.GetItemAsset("Common", "click");
 
-            Font font0 = GFGAsset.Load<Font>(ResPathUtil.GetFontPath("FangZhengHeiTiJianTi-1", "ttf"));
-            FontManager.RegisterFont(new DynamicFont("FangZhengHeiTiJianTi-1", font0));
-            Font font1 = GFGAsset.Load<Font>(ResPathUtil.GetFontPath("FZKTJW--GB1-0", "ttf"));
-            FontManager.RegisterFont(new DynamicFont("FZKTJW--GB1-0", font1));
-            Font font2 = GFGAsset.Load<Font>(ResPathUtil.GetFontPath("SourceHanSerifCN-Regular-1", "otf"));
-            FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-Regular-1", font2));
-            Font font3 = GFGAsset.Load<Font>(ResPathUtil.GetFontPath("SourceHanSerifCN-Bold-2", "otf"));
-            FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-Bold-2", font3));
-            Font font4 = GFGAsset.Load<Font>(ResPathUtil.GetFontPath("SourceHanSerifCN-ExtraLight-3", "otf"));
-            FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-ExtraLight-3", font4));
-            Font font5 = GFGAsset.Load<Font>(ResPathUtil.GetFontPath("SourceHanSerifCN-Heavy-4", "otf"));
-            FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-Heavy-4", font5));
-            Font font6 = GFGAsset.Load<Font>(ResPathUtil.GetFontPath("SourceHanSerifCN-Light-5", "otf"));
-            FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-Light-5", font6));
-            Font font7 = GFGAsset.Load<Font>(ResPathUtil.GetFontPath("SourceHanSerifCN-Medium-6", "otf"));
-            FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-Medium-6", font7));
-            Font font8 = GFGAsset.Load<Font>(ResPathUtil.GetFontPath("SourceHanSerifCN-SemiBold-7", "otf"));
-            FontManager.RegisterFont(new DynamicFont("SourceHanSerifCN-SemiBold-7", font8));
-
             UIConfig.defaultFont = "FZKTJW--GB1-0";
             //默认关闭点击窗口移至顶层的功能,不可打开,如哪个界面需要在界面中单独设置
             UIConfig.bringWindowToFrontOnClick = false;
@@ -474,5 +456,6 @@ namespace GFGGame
             }
             onSuccess?.Invoke();
         }
+
     }
 }

+ 30 - 10
GameClient/Assets/Game/Launcher/GFGAsset/AssetReleaser.cs

@@ -1,4 +1,4 @@
-using System.Collections;
+using UniFramework.Pooling;
 using UnityEngine;
 using YooAsset;
 
@@ -7,22 +7,34 @@ namespace GFGGame
     public class AssetReleaser : MonoBehaviour
     {
 
-        private string _resPath;
-        public string resPath
+        private string resPath;
+        public string ResPath
         {
             get
             {
-                return _resPath;
+                return resPath;
             }
         }
 
-        private AssetOperationHandle _handle;
+        private AssetOperationHandle assetOperationHandle;
+        private SpawnHandle spawnHandle;
+
+        public bool IsSpawn
+        {
+            get { return spawnHandle != null; }
+        }
 
         public void SetRes(string resPath, AssetOperationHandle handle)
         {
             Dispose();
-            this._resPath = resPath;
-            this._handle = handle;
+            this.resPath = resPath;
+            this.assetOperationHandle = handle;
+        }
+
+        public void SetSpawn(string resPath, SpawnHandle handle)
+        {
+            this.resPath = resPath;
+            this.spawnHandle = handle;
         }
 
         private void OnDestroy()
@@ -37,9 +49,17 @@ namespace GFGGame
 
         private void Dispose()
         {
-            this._handle?.Release();
-            this._handle = null;
-            this._resPath = null;
+            this.assetOperationHandle?.Release();
+            this.assetOperationHandle = null;
+            this.spawnHandle = null;
+            this.resPath = null;
         }
+
+        public void Restore()
+        {
+            this.spawnHandle?.Restore();
+            this.spawnHandle = null;
+        }
+
     }
 }

+ 0 - 52
GameClient/Assets/Game/Launcher/GFGAsset/GFGAsset.cs

@@ -1,52 +0,0 @@
-using UnityEngine;
-using YooAsset;
-
-namespace GFGGame
-{
-    public class GFGAsset
-    {
-        public static T Load<T>(string path) where T : Object
-        {
-            //VEngine.Logger.I($"GFGAsset.Load {path} {Random.Range(0, int.MaxValue)}");
-            T t = null;
-            if (path.Contains("Asset"))
-            {
-                //Asset asset = VEngine.Asset.Load(path, typeof(T));
-                //if (asset != null)
-                //{
-                //    t = asset.asset as T;
-                //}
-                ResourcePackage package;
-                //if (path.Contains("Assets/Res/") && !path.Contains("Assets/Res/Animation"))
-                //{
-                //    package = YooAssets.GetPackage(VersionController.PackageName_GameArt);
-                //}
-                //else
-                //{
-                    package = YooAssets.GetPackage(VersionController.DefaultPackage);
-                //}
-                AssetOperationHandle handle = package.LoadAssetSync<T>(path);
-                if(handle != null)
-                {
-                    var t1 = typeof(T);
-                    var t2 = typeof(GameObject);
-                    if (t1 == t2)
-                    {
-                        var t3 = handle.InstantiateSync();
-                        t = t3 as T;
-                    }
-                    else
-                    {
-                        t = handle.AssetObject as T;
-                    }
-                }
-            }
-            else
-            {
-                t = Resources.Load<T>(path);
-            }
-            return t;
-        }
-
-    }
-}

+ 0 - 32
GameClient/Assets/Game/Launcher/GFGAsset/GFGSpawner.cs

@@ -1,32 +0,0 @@
-using UniFramework.Pooling;
-using UnityEngine;
-using System.Collections.Generic;
-
-namespace GFGGame
-{
-    public class GFGSpawner
-    {
-        private Spawner _entitySpawner;
-        private Dictionary<string, bool> poolCreated = new Dictionary<string, bool>();
-
-        public void Init()
-        {
-            // 创建游戏对象发生器
-            _entitySpawner = UniPooling.CreateSpawner(VersionController.DefaultPackage);
-        }
-
-        public GameObject SpawnSync(string resPath)
-        {
-            poolCreated.TryGetValue(resPath, out bool created);
-            if (!created)
-            {
-                // 创建游戏对象池
-                _entitySpawner.CreateGameObjectPoolAsync(resPath);
-            }
-
-            var handle = _entitySpawner.SpawnSync(resPath);
-            return handle.GameObj;
-        }
-
-    }
-}

+ 64 - 0
GameClient/Assets/Game/Launcher/GFGAsset/PrefabManager.cs

@@ -0,0 +1,64 @@
+using UniFramework.Pooling;
+using UnityEngine;
+using System.Collections.Generic;
+using YooAsset;
+
+namespace GFGGame
+{
+    public class PrefabManager : SingletonBase<PrefabManager>
+    {
+        private Spawner _entitySpawner;
+        private Dictionary<string, bool> poolCreated = new Dictionary<string, bool>();
+
+        public void Init()
+        {
+            // 创建游戏对象发生器
+            _entitySpawner = UniPooling.CreateSpawner(VersionController.DefaultPackage);
+        }
+
+        public GameObject SpawnSync(string resPath)
+        {
+            this.poolCreated.TryGetValue(resPath, out bool poolCreated);
+            if (!poolCreated)
+            {
+                // 创建游戏对象池,销毁时间单位为秒
+                _entitySpawner.CreateGameObjectPoolAsync(resPath, false, 0, 1, 60);
+            }
+
+            var handle = _entitySpawner.SpawnSync(resPath);
+            var assetReleaser = handle.GameObj.GetComponent<AssetReleaser>();
+            if (assetReleaser == null)
+            {
+                assetReleaser = handle.GameObj.AddComponent<AssetReleaser>();
+            }
+            assetReleaser.SetSpawn(resPath, handle);
+            return handle.GameObj;
+        }
+
+        public GameObject InstantiateSync(string resPath)
+        {
+             AssetOperationHandle handle = YooAssets.LoadAssetSync<GameObject>(resPath);
+            GameObject gameObject = handle.InstantiateSync();
+            AssetReleaser assetReleaser = gameObject.AddComponent<AssetReleaser>();
+            assetReleaser.SetRes(resPath, handle);
+            return gameObject;
+        }
+
+        public void Restore(GameObject gameObject)
+        {
+            if (gameObject == null)
+            {
+                return;
+            }
+            AssetReleaser assetRestorer = gameObject.GetComponent<AssetReleaser>();
+            if (assetRestorer != null && assetRestorer.IsSpawn)
+            {
+                assetRestorer.Restore();
+            }
+            else
+            {
+                GameObject.DestroyImmediate(gameObject);
+            }
+        }
+    }
+}

+ 0 - 0
GameClient/Assets/Game/Launcher/GFGAsset/GFGSpawner.cs.meta → GameClient/Assets/Game/Launcher/GFGAsset/PrefabManager.cs.meta