From 485db99b5c51a971c173664cf6e808dc8424b0a0 Mon Sep 17 00:00:00 2001
From: lcy <1459594991@qq.com>
Date: 星期五, 17 十月 2025 17:19:51 +0800
Subject: [PATCH] 136 子 【挑战】战锤秘境 / 【挑战】战锤秘境-客户端 移除错误接入

---
 Main/ResModule/UILoader.cs |  416 ++++++++--------------------------------------------------
 1 files changed, 60 insertions(+), 356 deletions(-)

diff --git a/Main/ResModule/UILoader.cs b/Main/ResModule/UILoader.cs
index b965037..7e8e0d7 100644
--- a/Main/ResModule/UILoader.cs
+++ b/Main/ResModule/UILoader.cs
@@ -7,368 +7,72 @@
 using UnityEngine.U2D;
 
 
-// public class UILoader
-// {
-//     readonly static string PREFAB_EXTERSION = ".prefab";
-//     readonly static string SPRITE_EXTERSION = ".png"; 
-//     readonly static string Spriteatlas_EXTERSION = ".spriteatlasv2";
+public class UILoader
+{
+    public static GameObject LoadWindow(string name)
+    {
+        return ResManager.Instance.LoadAsset<GameObject>(ResourcesPath.UI_WINDOW_SUFFIX, name);
+    }
 
-//     public static GameObject LoadWindow(string name)
-//     {
-//         GameObject window = null;
-//         if (AssetSource.uiFromEditor)
-//         {
-// #if UNITY_EDITOR
-//             var isPriority = false;//PriorityWindowConfig.Get().priorityWindows.Contains(name);
+    public static GameObject LoadPrefab(string _name)
+    {
+        return ResManager.Instance.LoadAsset<GameObject>(ResourcesPath.UI_PREFAB_SUFFIX, _name);
+    }
 
-//             var path = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath,
-//                                                                 isPriority ? ResourcesPath.UI_PRIORITYWINDOW_SUFFIX : ResourcesPath.UI_WINDOW_SUFFIX, "/",
-//                                                                 name,
-//                                                                 PREFAB_EXTERSION);
+    public static void UnLoadPrefab(string _assetName)
+    {
+        ResManager.Instance.UnloadAsset(ResourcesPath.UI_PREFAB_SUFFIX, _assetName);
+    }
 
-//             window = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(path);
-// #endif
-//         }
-//         else
-//         {
-//             // var isPriority = PriorityWindowConfig.Get().priorityWindows.Contains(name);
-//             var bundleName = "ui/window";
+    //閫氳繃ICON琛ㄥ姞杞�
+    public static Sprite LoadSprite(string _iconKey)
+    {
+        var iconConfig = IconConfig.Get(_iconKey);
+        if (iconConfig == null)
+        {
+            return null;
+        }
 
-//             var assetInfo = new AssetInfo(bundleName, name);
+        return LoadSprite(iconConfig.folder, iconConfig.sprite);
+    }
 
-//             window = AssetBundleUtility.Instance.Sync_LoadAsset(assetInfo) as GameObject;
-//         }
+    public static Sprite LoadSprite(string _folder, string _file)
+    {
+        return ResManager.Instance.LoadAsset<Sprite>(StringUtility.Contact(ResourcesPath.UI_SPRITE_SUFFIX, "/", _folder), _file);
+    }
 
-//         if (window == null)
-//         {
-//             Debug.LogErrorFormat("UILoader.LoadWindow() => 鍔犺浇涓嶅埌璧勬簮: {0}.", name);
-//         }
+    public static void UnLoadSprite(string _iconKey)
+    {
+        var iconConfig = IconConfig.Get(_iconKey);
+        if (iconConfig != null)
+        {
+            var bundleName = StringUtility.Contact(ResourcesPath.UI_SPRITE_SUFFIX, "/", iconConfig.folder);
+            ResManager.Instance.UnloadAsset(bundleName, iconConfig.sprite);
+        }
+    }
 
-//         return window;
-//     }
+    public static Font LoadFont(string _fontName)
+    {
+        return ResManager.Instance.LoadAsset<Font>(ResourcesPath.UI_FONT_SUFFIX, _fontName);
+    }
 
-//     public static void LoadWindowAsync(string _name, Action<bool, UnityEngine.Object> _callBack)
-//     {
-//         GameObject window = null;
-//         if (AssetSource.uiFromEditor)
-//         {
-// #if UNITY_EDITOR
-//             var isPriority = PriorityWindowConfig.Get().priorityWindows.Contains(_name);
-//             var path = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath,
-//                                                                isPriority ? ResourcesPath.UI_PRIORITYWINDOW_SUFFIX : ResourcesPath.UI_WINDOW_SUFFIX, "/",
-//                                                                _name,
-//                                                                PREFAB_EXTERSION);
+    public static void UnLoadFont(string _fontName)
+    {
+        ResManager.Instance.UnloadAsset(ResourcesPath.UI_FONT_SUFFIX, _fontName);
+    }
 
-//             window = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(path);
-//             if (_callBack != null)
-//             {
-//                 _callBack(window != null, window);
-//             }
-// #endif
-//         }
-//         else
-//         {
-//             var isPriority = PriorityWindowConfig.Get().priorityWindows.Contains(_name);
-//             var bundleName = isPriority ? StringUtility.Contact("ui/prioritywindow/", _name) : "ui/window";
-//             var assetInfo = new AssetInfo(bundleName, _name);
-
-//             AssetBundleUtility.Instance.Co_LoadAsset(assetInfo, _callBack);
-//         }
-//     }
-
-//     public static void UnLoadWindowAsset(string _assetName)
-//     {
-//         if (!AssetSource.uiFromEditor)
-//         {
-//             var isPriority = PriorityWindowConfig.Get().priorityWindows.Contains(_assetName);
-//             var bundleName = isPriority ? StringUtility.Contact("ui/prioritywindow/", _assetName) : "ui/window";
-
-//             AssetBundleUtility.Instance.UnloadAsset(bundleName, _assetName);
-//         }
-//     }
-
-//     public static void UnLoadPriorityWindow(string windowName)
-//     {
-//         if (!AssetSource.uiFromEditor)
-//         {
-//             var assetBundleName = StringUtility.Contact("ui/prioritywindow/", windowName.ToLower());
-//             AssetBundleUtility.Instance.UnloadAssetBundle(assetBundleName, true, false);
-
-//             switch (windowName)
-//             {
-//                 case "LoginWin":
-//                     AssetBundleUtility.Instance.UnloadAssetBundle("ui/sprite/login", true, false);
-//                     break;
-//                 case "SelectRoleWin":
-//                 case "CreateRoleWin":
-//                     AssetBundleUtility.Instance.UnloadAssetBundle("ui/sprite/createrole", true, false);
-//                     break;
-//             }
-//         }
-//     }
-
-//     public static GameObject LoadPrefab(string _name)
-//     {
-//         GameObject prefab = null;
-//         if (AssetSource.uiFromEditor)
-//         {
-// #if UNITY_EDITOR
-//             var path = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath,
-//                                                                    ResourcesPath.UI_PREFAB_SUFFIX, "/",
-//                                                                    _name,
-//                                                                    PREFAB_EXTERSION);
-
-//             prefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(path);
-// #endif
-//         }
-//         else
-//         {
-//             var bundleName = ResourcesPath.UI_PREFAB_SUFFIX.ToLower();
-//             var assetInfo = new AssetInfo(bundleName, _name);
-
-//             prefab = AssetBundleUtility.Instance.Sync_LoadAsset(assetInfo) as GameObject;
-//         }
-
-//         if (prefab == null)
-//         {
-//             Debug.LogErrorFormat("UILoader.LoadPrefab() => 鍔犺浇涓嶅埌璧勬簮: {0}.", _name);
-//         }
-
-//         return prefab;
-//     }
-
-//     public static void UnLoadPrefab(string _assetName)
-//     {
-//         if (!AssetSource.uiFromEditor)
-//         {
-//             AssetBundleUtility.Instance.UnloadAsset("ui/prefab", _assetName);
-//         }
-//     }
-
-//     public static Sprite LoadSprite(string _iconKey)
-//     {
-//         var iconConfig = IconConfig.Get(_iconKey);
-//         if (iconConfig == null)
-//         {
-//             return null;
-//         }
-
-//         return LoadSprite(iconConfig.folder, iconConfig.sprite);
-//     }
-
-//     public static Sprite LoadSprite(string _folder, string _file)
-//     {
-//         var folder = _folder;
-//         var file = _file;
-
-//         Sprite sprite = null;
-//         if (AssetSource.uiFromEditor)
-//         {
-// #if UNITY_EDITOR
-//             var relativePath = folder;
-//             var rootPath = ResourcesPath.UI_SPRITE_SUFFIX;
-//             var path = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath,
-//                                                                  rootPath, "/",
-//                                                                  relativePath,
-//                                                                  Spriteatlas_EXTERSION);
-
-//             var spriteAtlas = UnityEditor.AssetDatabase.LoadAssetAtPath<SpriteAtlas>(path);
-//             sprite = spriteAtlas.GetSprite(file);
-// #endif
-//         }
-//         else
-//         {
-//             var bundleName = StringUtility.Contact("ui/sprite/", folder.ToLower());
-//             //var assetInfo = new AssetInfo(bundleName, folder);
-
-//             //var spriteAtlas = AssetBundleUtility.Instance.Sync_LoadAsset(assetInfo, typeof(SpriteAtlas)) as SpriteAtlas;
-//             //sprite = spriteAtlas?.GetSprite(_file);
-//             var assetInfo = new AssetInfo(bundleName, file);
-
-//             sprite = AssetBundleUtility.Instance.Sync_LoadAsset(assetInfo, typeof(Sprite)) as Sprite;
-//         }
-
-//         if (sprite == null)
-//         {
-//             Debug.LogErrorFormat("UILoader.LoadSprite() => 鍔犺浇涓嶅埌璧勬簮: {0}.", file);
-//         }
-
-//         return sprite;
-//     }
-
-//     public static void UnLoadSprite(string _iconKey)
-//     {
-//         if (!AssetSource.uiFromEditor)
-//         {
-//             var iconConfig = IconConfig.Get(_iconKey);
-//             if (iconConfig != null)
-//             {
-//                 var bundleName = StringUtility.Contact("ui/sprite/", iconConfig.folder.ToLower());
-//                 AssetBundleUtility.Instance.UnloadAsset(bundleName, iconConfig.sprite);
-//             }
-//         }
-
-//     }
-
-//     public static Font LoadFont(string _fontName)
-//     {
-//         Font font = null;
-//         if (AssetSource.uiFromEditor)
-//         {
-// #if UNITY_EDITOR
-//             var rootPath = ResourcesPath.UI_FONT_SUFFIX;
-//             var path = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath, rootPath, "/", _fontName, ".ttf");
-//             font = UnityEditor.AssetDatabase.LoadAssetAtPath<Font>(path);
-// #endif
-//         }
-//         else
-//         {
-//             var assetInfo = new AssetInfo("ui/font", _fontName);
-//             font = AssetBundleUtility.Instance.Sync_LoadAsset(assetInfo, typeof(Font)) as Font;
-//         }
-
-//         if (font == null)
-//         {
-//             Debug.LogErrorFormat("UILoader.LoadFont() => 鍔犺浇涓嶅埌璧勬簮: {0}.", _fontName);
-//         }
-
-//         return font;
-//     }
-
-//     public static void UnLoadFont(string _fontName)
-//     {
-//         if (!AssetSource.uiFromEditor)
-//         {
-//             AssetBundleUtility.Instance.UnloadAsset("ui/font", _fontName);
-//         }
-//     }
-
-//     public static GameObject LoadTreasure(string folder, string name)
-//     {
-//         GameObject prefab = null;
-//         if (AssetSource.uiFromEditor)
-//         {
-// #if UNITY_EDITOR
-//             var path = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath,
-//                                                                    "UI/Treasure/", folder, "/",
-//                                                                    name,
-//                                                                    PREFAB_EXTERSION);
-
-//             prefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(path);
-// #endif
-//         }
-//         else
-//         {
-//             var bundleName = StringUtility.Contact("ui/treasure/", folder).ToLower();
-//             var assetInfo = new AssetInfo(bundleName, name);
-
-//             prefab = AssetBundleUtility.Instance.Sync_LoadAsset(assetInfo) as GameObject;
-//         }
-
-//         if (prefab == null)
-//         {
-//             Debug.LogErrorFormat("UILoader.LoadPrefab() => 鍔犺浇涓嶅埌璧勬簮: {0}.", name);
-//         }
-
-//         return prefab;
-//     }
-
-//     public static void UnLoadTreasure(string folder, string _assetName)
-//     {
-//         if (!AssetSource.uiFromEditor)
-//         {
-//             AssetBundleUtility.Instance.UnloadAsset(StringUtility.Contact("ui/treasure/", folder).ToLower(), _assetName);
-//         }
-//     }
-
-//     public static GameObject LoadFaqi(string pathName, string name)
-//     {
-//         GameObject prefab = null;
-//         if (AssetSource.uiFromEditor)
-//         {
-// #if UNITY_EDITOR
-//             var path = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath,
-//                                                                    //"UI/Treasure/", folder, "/",
-//                                                                    pathName,
-//                                                                    name,
-//                                                                    PREFAB_EXTERSION);
-
-//             prefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(path);
-// #endif
-//         }
-//         else
-//         {
-//             var bundleName = pathName; //StringUtility.Contact("ui/treasure/", folder).ToLower();
-//             var assetInfo = new AssetInfo(bundleName, name);
-
-//             prefab = AssetBundleUtility.Instance.Sync_LoadAsset(assetInfo) as GameObject;
-//         }
-
-//         if (prefab == null)
-//         {
-//             Debug.LogErrorFormat("UILoader.LoadFaqi() => 鍔犺浇涓嶅埌璧勬簮: {0}.", name);
-//         }
-
-//         return prefab;
-//     }
-
-
-//     public static GameObject LoadGodWeapon(string _name)
-//     {
-//         GameObject prefab = null;
-//         if (AssetSource.uiFromEditor)
-//         {
-// #if UNITY_EDITOR
-//             var path = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath,
-//                                                                    "UI/GodWeapon/",
-//                                                                    _name,
-//                                                                    PREFAB_EXTERSION);
-
-//             prefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(path);
-// #endif
-//         }
-//         else
-//         {
-//             var bundleName = "ui/godweapon";
-//             var assetInfo = new AssetInfo(bundleName, _name);
-//             prefab = AssetBundleUtility.Instance.Sync_LoadAsset(assetInfo) as GameObject;
-//         }
-
-//         if (prefab == null)
-//         {
-//             Debug.LogErrorFormat("UILoader.LoadGodWeapon() => 鍔犺浇涓嶅埌璧勬簮: {0}.", _name);
-//         }
-
-//         return prefab;
-//     }
-
-//     public static GameObject LoadBossShow(string _name)
-//     {
-//         GameObject prefab = null;
-//         if (AssetSource.uiFromEditor)
-//         {
-// #if UNITY_EDITOR
-//             var path = StringUtility.Contact(ResourcesPath.ResourcesOutAssetPath,
-//                                                                    "UI/BossShow/",
-//                                                                    _name,
-//                                                                    PREFAB_EXTERSION);
-
-//             prefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(path);
-// #endif
-//         }
-//         else
-//         {
-//             var bundleName = "ui/bossshow";
-//             var assetInfo = new AssetInfo(bundleName, _name);
-//             prefab = AssetBundleUtility.Instance.Sync_LoadAsset(assetInfo) as GameObject;
-//         }
-
-//         if (prefab == null)
-//         {
-//             Debug.LogErrorFormat("UILoader.LoadBossShow() => 鍔犺浇涓嶅埌璧勬簮: {0}.", _name);
-//         }
-
-//         return prefab;
-//     }
-
-// }
+    public static Texture2D LoadTexture2D(string _iconKey)
+    {
+        var iconConfig = IconConfig.Get(_iconKey);
+        if (iconConfig == null)
+        {
+            return null;
+        }
+        return ResManager.Instance.LoadAsset<Texture2D>(StringUtility.Contact(ResourcesPath.UI_TEXTURE_SUFFIX, "/" + iconConfig.folder), iconConfig.sprite);
+    }
+    
+    public static Texture2D LoadTexture2DPNG(string name)
+    {
+        return ResManager.Instance.LoadAsset<Texture2D>(StringUtility.Contact(ResourcesPath.UI_TEXTURE_SUFFIX, "/FullScreenBg"), name + ".png", false);
+    }
+}

--
Gitblit v1.8.0