Przeglądaj źródła

UI包的资源改回同步加载

guodong 1 rok temu
rodzic
commit
070195b5fd

+ 0 - 4
GameClient/Assets/Game/HotUpdate/Controller/GameController.cs

@@ -14,10 +14,6 @@ namespace GFGGame
             PrefabManager.Instance.Init();
             //字体
             await FontLoader.Instance.Init();
-            //通用资源
-            await GFGUIPackage.AddPackageAsync(ResPathUtil.GetUIPackagePath("Common"));
-            await GFGUIPackage.AddPackageAsync(ResPathUtil.GetUIPackagePath("CommonGame"));
-            await GFGUIPackage.AddPackageAsync(ResPathUtil.GetUIPackagePath("Main"));
             //界面
             ViewManager.Init();
             //日志

+ 0 - 33
GameClient/Assets/Game/HotUpdate/FairyGUI/GFGUIPackage.cs

@@ -37,39 +37,6 @@ namespace GFGGame
                 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;
-            //    if (!YooAssets.CheckResExist(location))
-            //    {
-            //        return;
-            //    }
-            //    AssetOperationHandle handle = YooAssets.LoadAssetAsync(location, type);
-            //    CacheAssetHandle(descFilePath, handle);
-            //    handle.Completed += (handle) =>
-            //    {
-            //        if (handle.AssetObject == null) return;
-            //        Texture tex = handle.AssetObject as Texture;
-            //        if (tex != null)
-            //        {
-            //            string location = name + "!a" + extension;
-            //            if (YooAssets.CheckResExist(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);
         }
 

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

@@ -148,7 +148,7 @@ namespace GFGGame
                 _ui.m_btnTapLogin.visible = QDManager.IsTaptap;
                 _ui.m_btnStart.visible = !QDManager.IsTaptap;
                 //尝试自动登录
-                OnClickBtnStart();
+                TryLogin();
             }
             else
             {
@@ -170,7 +170,7 @@ namespace GFGGame
             {
                 ViewManager.Hide<ModalStatusView>();
                 //尝试自动登录
-                OnClickBtnStart();
+                TryLogin();
             }
         }
 
@@ -202,6 +202,21 @@ namespace GFGGame
 
         private void OnClickBtnStart()
         {
+            TryLogin();
+        }
+
+        private void OnClickBtnLogout()
+        {
+            GameController.QuitToLoginView(true);
+        }
+        private void OnClickBtnAge()
+        {
+            ViewManager.Show<SystemNoticeView>(new object[] { LoginController.ageTipsTitle, LoginController.ageTips });
+        }
+
+
+        private void TryLogin()
+        {
             var serverInfosComponent = GameGlobal.zoneScene.GetComponent<ServerInfosComponent>();
             if (serverInfosComponent.ServerInfoList.Count <= 0)
             {
@@ -217,19 +232,5 @@ namespace GFGGame
                 LoginController.GetRoles().Coroutine();
             }
         }
-
-        private void OnClickBtnLogout()
-        {
-            GameController.QuitToLoginView(true);
-        }
-        private void OnClickBtnAge()
-        {
-            ViewManager.Show<SystemNoticeView>(new object[] { LoginController.ageTipsTitle, LoginController.ageTips });
-        }
-
-        //private void OnBtnAgreeCklick()
-        //{
-        //    LocalCache.SetBool(LauncherConfig.LAST_LOGIN_IS_AGREE_KEY, _ui.m_btnAgree.selected);
-        //}
     }
 }

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

@@ -35,6 +35,11 @@ namespace GFGGame
 
         public static void Init()
         {
+            //通用资源,单独加,增加一次引用,不会被释放
+            GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("Common"));
+            GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("CommonGame"));
+            GFGUIPackage.AddPackage(ResPathUtil.GetUIPackagePath("Main"));
+
             //await GFGUIPackage.AddPackageAsync(ResPathUtil.GetUIPackagePath("Common"));
             UIConfig.buttonSound = (NAudioClip)UIPackage.GetItemAsset("Common", "click");
 

+ 15 - 6
GameClient/Assets/Game/Launcher/FairyGUI/GFGGLoader.cs

@@ -6,20 +6,29 @@ namespace GFGGame
 {
     public class GFGGLoader : GLoader
     {
+        private bool ASYNC = true;
+
         private AssetOperationHandle handle;
 
         protected override void LoadExternal()
         {
+            Debug.Log($"GFGGLoader this.url {this.url}");
             if (!YooAssets.CheckResExist(this.url))
             {
                 return;
             }
-            //异步
-            handle = YooAssets.LoadAssetAsync<Texture2D>(this.url);
-            handle.Completed += Handle_Completed;
-            //同步
-            //handle = YooAssets.LoadAssetSync<Texture2D>(this.url);
-            //Handle_Completed(handle);
+            if(ASYNC)
+            {
+                //异步
+                handle = YooAssets.LoadAssetAsync<Texture2D>(this.url);
+                handle.Completed += Handle_Completed;
+            }
+            else
+            {
+                //同步
+                handle = YooAssets.LoadAssetSync<Texture2D>(this.url);
+                Handle_Completed(handle);
+            }
         }
 
         protected override void FreeExternal(NTexture texture)