From 862aeae51fdc2c8abd8753ac8d72c2ef2f07c03e Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期二, 31 三月 2026 11:39:32 +0800
Subject: [PATCH] 0312 服务器列表查找增加测试组

---
 Main/ResModule/ResManager.cs |   79 +++++++++++++++++++++++++++++++++------
 1 files changed, 66 insertions(+), 13 deletions(-)

diff --git a/Main/ResModule/ResManager.cs b/Main/ResModule/ResManager.cs
index 56bbfb3..8c8ac21 100644
--- a/Main/ResModule/ResManager.cs
+++ b/Main/ResModule/ResManager.cs
@@ -5,6 +5,11 @@
 using System.IO;
 using UnityEngine.Video;
 using Spine.Unity;
+using UnityEngine.UI;
+using Cysharp.Threading.Tasks;
+
+
+
 
 
 
@@ -67,7 +72,7 @@
         {typeof(Sprite), "png"},
         {typeof(Texture2D), "jpg"},
         {typeof(Texture), "jpg"},
-        { typeof(Shader), "shader"},
+        {typeof(Shader), "shader"},
         {typeof(TextAsset), "txt"},
         {typeof(AudioClip), "wav"},
         {typeof(Font), "ttf"},
@@ -123,8 +128,11 @@
     }
 #endif
 
-    public T LoadAsset<T> (string directory, string name) where T : UnityEngine.Object
+    //needExt 鏄惁闇�瑕佸嚱鏁板唴閮ㄦ坊鍔犲悗缂�
+    public T LoadAsset<T>(string directory, string name, bool needExt = true) where T : UnityEngine.Object
     {
+        directory = directory.Replace("\\", "/");
+        name = name.Replace("\\", "/");
         T asset = null;
         //  鐗规畩澶勭悊 鍥犱负鏈変竴灞傚浘闆嗙殑鍏崇郴 directory瑕佷紶鍏ョ殑搴旇鏄痑tlas鐨勫悕瀛�
         if (typeof(T) == typeof(Sprite))
@@ -140,17 +148,17 @@
                 name = name.Substring(name.LastIndexOf("/") + 1);
             }
 
-            directory = directory.Replace("\\", "/");
         }
 
-        return LoadAssetInternal<T>(directory, name);
+        return LoadAssetInternal<T>(directory, name, needExt);
     }
 
-    private T LoadAssetInternal<T>(string directory, string name) where T : UnityEngine.Object
+    //needExt 鏄惁闇�瑕佸嚱鏁板唴閮ㄦ坊鍔犲悗缂�
+    private T LoadAssetInternal<T>(string directory, string name, bool needExt = true) where T : UnityEngine.Object
     {
         T asset = null;
+        var path = ($"Assets/ResourcesOut/{directory}/{name}" + (needExt ? GetExtension(typeof(T)) : "")).Replace("//", "/").Trim().Replace("\\", "/");
 
-        var path = ($"Assets/ResourcesOut/{directory}/{name}" + GetExtension(typeof(T))).Replace("//", "/").Trim().Replace("\\", "/");
         if (!AssetSource.isUseAssetBundle)
         {
 #if UNITY_EDITOR
@@ -159,9 +167,15 @@
         }
         else
         {
+            if (!needExt)
+            {
+                //澶栭儴鐢ㄥ埌鐨勮嚜宸卞姞鍚庣紑锛屽唴閮ㄧ粺涓�鍘婚櫎鍚庣紑鍚�
+                name = name.Substring(0, name.LastIndexOf("."));
+            }
+            //TODO: 涓存椂鐗规畩澶勭悊鎵撳寘鍚庣殑璺緞璇诲彇
             if (directory == "UI" || directory == "UIComp" || directory.StartsWith("Sprite")
             || directory == "Battle/Prefabs" || directory == "Materials")
-            { 
+            {
                 directory = "UI/" + directory;
             }
             else if (name == "Hero_001")
@@ -171,8 +185,13 @@
 
             else if (directory.Contains("Texture"))
             {
-                directory = "maps/"+name;
+                directory = "maps/" + name;
             }
+            else if (directory.Contains("Shader"))
+            {
+                directory = "graphic/shader";
+            }
+
 
             var assetInfo = new AssetInfo(directory.ToLower(), name.ToLower());
             asset = AssetBundleUtility.Instance.Sync_LoadAsset(assetInfo, typeof(T)) as T;
@@ -206,24 +225,58 @@
     private Sprite LoadSprite(string atlasName, string spriteName)
     {
         if (!AssetSource.isUseAssetBundle)
-        { 
+        {
             SpriteAtlas atlas = LoadAsset<SpriteAtlas>("Sprite", atlasName.Replace("Sprite/", ""));
+            if (null == atlas)
+            {
+                return null;
+            }
             return atlas.GetSprite(spriteName);
         }
         else
             return LoadAssetInternal<Sprite>(atlasName, spriteName);
     }
 
-    public void LoadAssetAsync<T>(string directory, string name, Action<bool, UnityEngine.Object> callBack) where T : UnityEngine.Object
+    //needExt 鏄惁闇�瑕佸嚱鏁板唴閮ㄦ坊鍔犲悗缂�
+    public void LoadAssetAsync<T>(string directory, string name, Action<bool, UnityEngine.Object> callBack, bool needExt = true) where T : UnityEngine.Object
     {
+        directory = directory.Replace("\\", "/");
+        name = name.Replace("\\", "/");
+
         //  鐗规畩澶勭悊 鍥犱负鏈変竴灞傚浘闆嗙殑鍏崇郴 directory瑕佷紶鍏ョ殑搴旇鏄痑tlas鐨勫悕瀛�
         if (typeof(T) == typeof(Sprite))
         {
             LoadSpriteAsync<T>(directory, name, callBack);
             return;
         }
+        else if (typeof(T) == typeof(SkeletonDataAsset))
+        {
+            //鏂囦欢鐩綍璋冩暣锛宯ame涓寘鍚簡璺緞
+            if (name.Contains("/"))
+            {
+                directory += name.Substring(0, name.LastIndexOf("/"));
+                name = name.Substring(name.LastIndexOf("/") + 1);
+            }
 
-        LoadAssetAsyncInternal<T>(directory, name, callBack);
+        }
+
+        LoadAssetAsyncInternal<T>(directory, name, callBack, needExt);
+    }
+
+    public async UniTask<T> LoadAssetAsync<T>(string directory, string name, bool needExt = true) where T : UnityEngine.Object
+    {
+        var tcs = new UniTaskCompletionSource<T>();
+        LoadAssetAsync<T>(directory, name, (isLoaded, asset) => {
+            if (isLoaded)
+            {
+                tcs.TrySetResult(asset as T);
+            }
+            else
+            {
+                tcs.TrySetException(new Exception($"Failed to load asset: {directory}/{name}"));
+            }
+        }, needExt);
+        return await tcs.Task;
     }
 
     private void LoadSpriteAsync<T>(string atlasName, string spriteName, Action<bool, UnityEngine.Object> callBack) where T : UnityEngine.Object
@@ -246,9 +299,9 @@
 #endif
     }
 
-    private void LoadAssetAsyncInternal<T>(string directory, string name, Action<bool, UnityEngine.Object> callBack) where T : UnityEngine.Object
+    private void LoadAssetAsyncInternal<T>(string directory, string name, Action<bool, UnityEngine.Object> callBack, bool needExt = true) where T : UnityEngine.Object
     {
-        var path = string.Concat($"Assets/ResourcesOut/{directory}/{name}", GetExtension(typeof(T))).Replace("//", "/");
+        var path = string.Concat($"Assets/ResourcesOut/{directory}/{name}", (needExt ? GetExtension(typeof(T)) : "")).Replace("//", "/");
 
         if (!AssetSource.isUseAssetBundle)
         {

--
Gitblit v1.8.0