From 51b0f6ed9f4e1d3bb6f8144470b46908c7699a96 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期一, 11 五月 2026 16:20:37 +0800
Subject: [PATCH] Merge branch 'master' into h5version

---
 Main/ResModule/BuiltInLoader.cs |  225 ++------------------------------------------------------
 1 files changed, 8 insertions(+), 217 deletions(-)

diff --git a/Main/ResModule/BuiltInLoader.cs b/Main/ResModule/BuiltInLoader.cs
index 2c69c14..98aee23 100644
--- a/Main/ResModule/BuiltInLoader.cs
+++ b/Main/ResModule/BuiltInLoader.cs
@@ -14,226 +14,17 @@
 
     readonly static List<string> excludePngs = new List<string>() { "Launch_1.png", "Launch_2.png", "Launch_3.png", "LoginBackGround.png", "TB_DL_Logo.png" };
 
-    public static Sprite LoadSprite(string name)
-    {
-        Sprite sprite = null;
-        if (!AssetSource.isUseAssetBundle)
-        {
-#if UNITY_EDITOR
-            if (excludePngs.Contains(StringUtility.Concat(name, SPRITE_EXTENSION)))
-            {
-                var path = StringUtility.Concat("Assets/ResourcesOut/BuiltIn/Sprites/", name, SPRITE_EXTENSION);
-                path = System.Text.RegularExpressions.Regex.Replace(path, @"[\p{C}]", "");
-                sprite = UnityEditor.AssetDatabase.LoadAssetAtPath<Sprite>(path);
-            }
-            else
-            {
-                var spriteAtlas = UnityEditor.AssetDatabase.LoadAssetAtPath<SpriteAtlas>("Assets/ResourcesOut/BuiltIn/Sprites/sprites.spriteatlasv2");
-                sprite = spriteAtlas.GetSprite(name);
-            }
-#endif
-        }
-        else
-        {
-            //if (sprite == null)
-            {
-                // US1: Route through YooAssetService sync wrapper
-                var path = StringUtility.Concat("Assets/ResourcesOut/BuiltIn/Sprites/", name, SPRITE_EXTENSION);
-                #pragma warning disable CS0612
-                sprite = YooAssetService.Instance.LoadAssetSync<Sprite>(path);
-                #pragma warning restore CS0612
-            }
-        }
-
-        if (sprite == null)
-        {
-            Debug.LogErrorFormat("BuiltInLoader.LoadSprite() => 鍔犺浇涓嶅埌璧勬簮: {0}.", name);
-        }
-
-        return sprite;
-    }
-
-    public static GameObject LoadPrefab(string name)
-    {
-        GameObject prefab = null;
-        if (!AssetSource.isUseAssetBundle)
-        {
-#if UNITY_EDITOR
-            var path = StringUtility.Concat("Assets/ResourcesOut/BuiltIn/Prefabs/", name, PREFAB_EXTENSION);
-            prefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(path);
-#endif
-        }
-        else
-        {
-            // US1: Route through YooAssetService sync wrapper
-            var path = StringUtility.Concat("Assets/ResourcesOut/BuiltIn/Prefabs/", name, PREFAB_EXTENSION);
-            #pragma warning disable CS0612
-            prefab = YooAssetService.Instance.LoadAssetSync<GameObject>(path);
-            #pragma warning restore CS0612
-        }
-
-        if (prefab == null)
-        {
-            Debug.LogErrorFormat("BuiltInLoader.LoadPrefab() => 鍔犺浇涓嶅埌璧勬簮: {0}.", name);
-        }
-
-        return prefab;
-    }
-
-    public static void UnLoadPrefab(string name)
-    {
-        // US1: No-op. YooAsset manages asset lifecycle via handle-based release.
-    }
-
-    public static AudioClip LoadMusic(string name)
-    {
-        AudioClip audioClip = null;
-        if (!AssetSource.isUseAssetBundle)
-        {
-#if UNITY_EDITOR
-            var path = StringUtility.Concat("Assets/ResourcesOut/BuiltIn/Musics/", name, ".mp3");
-            audioClip = UnityEditor.AssetDatabase.LoadAssetAtPath<AudioClip>(path);
-#endif
-        }
-        else
-        {
-            // US1: Route through YooAssetService sync wrapper
-            var path = StringUtility.Concat("Assets/ResourcesOut/BuiltIn/Musics/", name, ".mp3");
-            #pragma warning disable CS0612
-            audioClip = YooAssetService.Instance.LoadAssetSync<AudioClip>(path);
-            #pragma warning restore CS0612
-        }
-
-        if (audioClip == null)
-        {
-            Debug.LogErrorFormat("BuiltInLoader.LoadMusic() => 鍔犺浇涓嶅埌璧勬簮: {0}.", name);
-        }
-
-        return audioClip;
-    }
-
-    public static AnimationClip LoadAnimationClip(string name)
-    {
-        AnimationClip clip = null;
-        if (!AssetSource.isUseAssetBundle)
-        {
-#if UNITY_EDITOR
-            var path = StringUtility.Concat("Assets/ResourcesOut/BuiltIn/AnimationClips/", name, ".anim");
-            clip = UnityEditor.AssetDatabase.LoadAssetAtPath<AnimationClip>(path);
-#endif
-        }
-        else
-        {
-            // US1: Route through YooAssetService sync wrapper
-            var path = StringUtility.Concat("Assets/ResourcesOut/BuiltIn/AnimationClips/", name, ".anim");
-            #pragma warning disable CS0612
-            clip = YooAssetService.Instance.LoadAssetSync<AnimationClip>(path);
-            #pragma warning restore CS0612
-        }
-
-        if (clip == null)
-        {
-            Debug.LogErrorFormat("BuiltInLoader.LoadAnimationClip() => 鍔犺浇涓嶅埌璧勬簮: {0}.", name);
-        }
-
-        return clip;
-    }
-
-    public static Material LoadMaterial(string name)
-    {
-        Material material = null;
-        if (!AssetSource.isUseAssetBundle)
-        {
-#if UNITY_EDITOR
-            var path = StringUtility.Concat("Assets/ResourcesOut/BuiltIn/Materials/", name, ".mat");
-            material = UnityEditor.AssetDatabase.LoadAssetAtPath<Material>(path);
-#endif
-        }
-        else
-        {
-            // US1: Route through YooAssetService sync wrapper
-            var path = StringUtility.Concat("Assets/ResourcesOut/BuiltIn/Materials/", name, ".mat");
-            #pragma warning disable CS0612
-            material = YooAssetService.Instance.LoadAssetSync<Material>(path);
-            #pragma warning restore CS0612
-        }
-
-        if (material == null)
-        {
-            Debug.LogErrorFormat("BuiltInLoader.LoadMaterial() => 鍔犺浇涓嶅埌璧勬簮: {0}.", name);
-        }
-
-        return material;
-    }
-
-    public static T LoadScriptableObject<T>(string name) where T : ScriptableObject
-    {
-
-        T config = null;
-        if (!AssetSource.isUseAssetBundle)
-        {
-#if UNITY_EDITOR
-            var resourcePath = StringUtility.Concat(ResourcesPath.ResourcesOutAssetPath,
-                                                   "BuiltIn/ScriptableObjects/", name, ".asset");
-
-            config = UnityEditor.AssetDatabase.LoadAssetAtPath<T>(resourcePath);
-#endif
-        }
-        else
-        {
-            // US1: Route through YooAssetService sync wrapper
-            var path = StringUtility.Concat(ResourcesPath.ResourcesOutAssetPath,
-                                           "BuiltIn/ScriptableObjects/", name, ".asset");
-            #pragma warning disable CS0612
-            config = YooAssetService.Instance.LoadAssetSync<T>(path);
-            #pragma warning restore CS0612
-        }
-
-        if (config == null)
-        {
-            Debug.LogErrorFormat("BuiltIn.LoadScriptableObject() => 鍔犺浇涓嶅埌璧勬簮: {0}.", name);
-        }
-
-        return config;
-    }
-
-    public static Font LoadFont(string fontName)
-    {
-        Font font = null;
-        if (!AssetSource.isUseAssetBundle)
-        {
-#if UNITY_EDITOR
-            var path = StringUtility.Concat(ResourcesPath.ResourcesOutAssetPath,
-                                       "BuiltIn/Font/", fontName, ".ttf");
-            font = UnityEditor.AssetDatabase.LoadAssetAtPath<Font>(path);
-#endif
-        }
-        else
-        {
-            // US1: Route through YooAssetService sync wrapper
-            var path = StringUtility.Concat(ResourcesPath.ResourcesOutAssetPath,
-                                       "BuiltIn/Font/", fontName, ".ttf");
-            #pragma warning disable CS0612
-            font = YooAssetService.Instance.LoadAssetSync<Font>(path);
-            #pragma warning restore CS0612
-        }
-
-        if (font == null)
-        {
-            Debug.LogErrorFormat("BuiltInLoader.LoadFont() => 鍔犺浇涓嶅埌璧勬簮: {0}.", fontName);
-        }
-
-        return font;
-    }
-
-    // ====================================================================
-    // US2: Async UniTask variants
-    // ====================================================================
+    // ...existing code...
 
     public static async UniTask<Sprite> LoadSpriteAsync(string name, CancellationToken ct = default)
     {
         var path = StringUtility.Concat("Assets/ResourcesOut/BuiltIn/Sprites/", name, SPRITE_EXTENSION);
-        return await YooAssetService.Instance.LoadAssetAsync<Sprite>(path, ct: ct);
+        var sprite = await YooAssetService.Instance.LoadAssetAsync<Sprite>(path, ct: ct);
+#if UNITY_WEBGL
+        if (sprite == null)
+            Debug.LogWarning($"[BuiltInLoader][WebGL-Diag] Sprite load returned NULL: path={path}");
+#endif
+        return sprite;
     }
 
     public static async UniTask<GameObject> LoadPrefabAsync(string name, CancellationToken ct = default)
@@ -270,7 +61,7 @@
     public static async UniTask<Font> LoadFontAsync(string fontName, CancellationToken ct = default)
     {
         var path = StringUtility.Concat(ResourcesPath.ResourcesOutAssetPath,
-                                       "BuiltIn/Font/", fontName, ".ttf");
+                                       "Font/", fontName, ".ttf");
         return await YooAssetService.Instance.LoadAssetAsync<Font>(path, ct: ct);
     }
 

--
Gitblit v1.8.0