瀏覽代碼

ui包加载

guodong 1 年之前
父節點
當前提交
11b97bd3d0

+ 3 - 3
GameClient/Assets/AssetBundleBuilderSetting.asset

@@ -12,11 +12,11 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 09788b4733bab2d4792fdd5d28e7653c, type: 3}
   m_Name: AssetBundleBuilderSetting
   m_EditorClassIdentifier: 
-  BuildPipeline: 0
+  BuildPipeline: 1
   BuildMode: 1
   BuildPackage: GameLogic
   CompressOption: 2
   OutputNameStyle: 1
-  CopyBuildinFileOption: 0
-  CopyBuildinFileTags: 
+  CopyBuildinFileOption: 2
+  CopyBuildinFileTags: preload
   EncyptionClassName: EncryptionNone

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

@@ -16,8 +16,12 @@ namespace GFGGame
             //字体
             await FontLoader.Instance.Init();
             //通用资源
-            await GFGUIPackage.AddPackageAsync(ResPathUtil.GetUIPackagePath("Common"));
             //GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("Common"));
+            //GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("CommonGame"));
+            //GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("Main"));
+            await GFGUIPackage.AddPackageAsync(ResPathUtil.GetUIPackagePath("Common"));
+            await GFGUIPackage.AddPackageAsync(ResPathUtil.GetUIPackagePath("CommonGame"));
+            await GFGUIPackage.AddPackageAsync(ResPathUtil.GetUIPackagePath("Main"));
             //界面
             ViewManager.Init();
             //日志
@@ -102,13 +106,9 @@ namespace GFGGame
         {
             QDManager.OnEnterGame();
             RoleDataHandler.StartUpdate();
-
-            await GFGUIPackage.AddPackageAsync(ResPathUtil.GetUIPackagePath("CommonGame"));
-            await GFGUIPackage.AddPackageAsync(ResPathUtil.GetUIPackagePath("Main"));
             //GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("CommonGame"));
             //GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("Main"));
 
-            LeagueSproxy.ReqGetLeagueInfo().Coroutine();
             await ItemProxy.GetItemInfos();
 
             await RoleLimitSProxy.ReqUnitLimitInfos();
@@ -212,6 +212,7 @@ namespace GFGGame
             ChatSProxy.ReqQueryChatMsg(ChatType.League).Coroutine();
             ChatSProxy.ReqQueryChatMsg(ChatType.LeagueQuestion).Coroutine();
             LuckyBoxSProxy.ReqGetLuckyBoxInfo().Coroutine();
+            LeagueSproxy.ReqGetLeagueInfo().Coroutine();
 
             int storageAutoPlay = StorageDataManager.Instance.GetStorageValue(ConstStorageId.STORAGE_AUTO_PLAY);
             FightDataManager.Instance.autoPlay = storageAutoPlay <= 0 ? false : true;

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

@@ -333,7 +333,7 @@ namespace GFGGame
         }
 
         //穿上一个动作
-        public void PutOnAction(int actionId)
+        private void PutOnAction(int actionId)
         {
             bool hasSuitActionRes = DressUpMenuSuitDataManager.CheckSuitHasActionRes(actionId);
             _dressUpData.actionId = actionId;

+ 42 - 10
GameClient/Assets/Game/HotUpdate/FairyGUI/GFGUIPackage.cs

@@ -2,7 +2,7 @@
 using System.Collections.Generic;
 using UnityEngine;
 using YooAsset;
-using ET;
+using System.Threading.Tasks;
 
 namespace GFGGame
 {
@@ -24,23 +24,55 @@ namespace GFGGame
             var handle = YooAssets.LoadAssetSync<TextAsset>($"{descFilePath}_fui.bytes");
             TextAsset textAsset = handle.AssetObject as TextAsset;
             CacheAssetHandle(descFilePath, handle);
-            var uiPackage = UIPackage.AddPackage(textAsset.bytes, descFilePath, (string name, string extension, System.Type type, out DestroyMethod destroyMethod) =>
+            //var uiPackage = UIPackage.AddPackage(textAsset.bytes, descFilePath, (string name, string extension, System.Type type, out DestroyMethod destroyMethod) =>
+            //{
+            //    string location = name + extension;
+            //    destroyMethod = DestroyMethod.None; //注意:这里一定要设置为None
+            //    if(!YooAssets.CheckDressUpResExist(location))
+            //    {
+            //        return null;
+            //    }
+            //    var handle = YooAssets.LoadAssetSync(location, type);
+            //    CacheAssetHandle(descFilePath, handle);
+            //    return handle.AssetObject;
+            //});
+
+            var uiPackage = UIPackage.AddPackage(textAsset.bytes, descFilePath, (string name, string extension, System.Type type, PackageItem item) =>
             {
                 string location = name + extension;
-                destroyMethod = DestroyMethod.None; //注意:这里一定要设置为None
-                if(!YooAssets.CheckDressUpResExist(location))
+                if (!YooAssets.CheckDressUpResExist(location))
                 {
-                    return null;
+                    return;
                 }
-                var handle = YooAssets.LoadAssetSync(location, type);
+                AssetOperationHandle handle = YooAssets.LoadAssetAsync(location, type);
                 CacheAssetHandle(descFilePath, handle);
-                return handle.AssetObject;
+                handle.Completed += (handle) =>
+                {
+                    if (handle.AssetObject == null) return;
+                    Texture tex = handle.AssetObject as Texture;
+                    if (tex != null)
+                    {
+                        string location = name + "!a" + extension;
+                        if (YooAssets.CheckDressUpResExist(location))
+                        {
+                            AssetOperationHandle handleAlpha = YooAssets.LoadAssetAsync(location, type);
+                            CacheAssetHandle(descFilePath, handleAlpha);
+                            handleAlpha.Completed += (handle1) =>
+                            {
+                                if (handle1.AssetObject == null) return;
+                                Texture alphaTex = handle1.AssetObject as Texture;
+                                item.owner.SetItemAsset(item, tex, alphaTex, DestroyMethod.None);//注意:这里一定要设置为None
+                            };
+                            return;
+                        }
+                    }
+                    item.owner.SetItemAsset(item, handle.AssetObject, null, DestroyMethod.None);//注意:这里一定要设置为None
+                };
             });
-
             _packages.Add(descFilePath, uiPackage);
         }
 
-        public static async ETTask AddPackageAsync(string descFilePath)
+        public static async Task AddPackageAsync(string descFilePath)
         {
             _assetCount.TryGetValue(descFilePath, out var count);
             if (count > 0)
@@ -66,7 +98,7 @@ namespace GFGGame
                 {
                     if (handle.AssetObject == null) return;
                     Texture tex = handle.AssetObject as Texture;
-                    if(tex != null)
+                    if (tex != null)
                     {
                         string location = name + "!a" + extension;
                         if (YooAssets.CheckDressUpResExist(location))

+ 7 - 0
GameClient/Assets/YooAsset/LICENSE.md.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: c7a71f2ca66f7a848acaed04af4665fa
+TextScriptImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: