From bc1cb6da854cb2e9144f10ed55330a537ecdca16 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期三, 04 三月 2026 14:35:57 +0800
Subject: [PATCH] 466 h5版本 资源规则修改 打包修改(未完成 勿拉取)
---
Main/ResModule/BuiltInLoader.cs | 216 -----------------------------------------------------
1 files changed, 1 insertions(+), 215 deletions(-)
diff --git a/Main/ResModule/BuiltInLoader.cs b/Main/ResModule/BuiltInLoader.cs
index cf52f32..8c00524 100644
--- a/Main/ResModule/BuiltInLoader.cs
+++ b/Main/ResModule/BuiltInLoader.cs
@@ -14,221 +14,7 @@
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,
- "Font/", fontName, ".ttf");
- font = UnityEditor.AssetDatabase.LoadAssetAtPath<Font>(path);
-#endif
- }
- else
- {
- // US1: Route through YooAssetService sync wrapper
- var path = StringUtility.Concat(ResourcesPath.ResourcesOutAssetPath,
- "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)
{
--
Gitblit v1.8.0