From 1ab047b5fdd933c38ba0519ec2e83a44512ea8d7 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期四, 26 三月 2026 17:46:11 +0800
Subject: [PATCH] webgl代码合并 1
---
Main/Utility/ShaderUtility.cs | 22 ++++++++++++++++++++--
1 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/Main/Utility/ShaderUtility.cs b/Main/Utility/ShaderUtility.cs
index 3e11810..c9f1188 100644
--- a/Main/Utility/ShaderUtility.cs
+++ b/Main/Utility/ShaderUtility.cs
@@ -21,19 +21,37 @@
public static void WarmUpAll()
{
// US2: Sync AB loading removed. Use WarmUpAllAsync instead.
+#if !UNITY_EDITOR
Shader.WarmupAllShaders();
+#endif
}
/// <summary>
- /// US2: Async shader warm up via YooAsset. Temporary API 鈥� will be replaced by preload+cache in T044.
+ /// US2: Async shader warm up via YooAsset.
+ /// PackDirectory 瑙勫垯涓嬫墍鏈� shader 鍦ㄥ悓涓�涓� bundle锛�
+ /// 閫氳繃 tag="shader" 鎷垮埌浠绘剰涓�涓湁鏁堝湴鍧�浼犵粰 LoadAllAssetsAsync 鍗冲彲鍔犺浇鏁村寘銆�
+ /// 鍓嶆彁锛欳ollector 鐨� Asset Tags 濉啓 "shader" 骞堕噸鏂版墦 AB銆�
/// </summary>
public static async UniTask WarmUpAllAsync()
{
if (AssetSource.isUseAssetBundle)
{
- await YooAssetService.Instance.LoadAllAssetsAsync<Shader>("Assets/ResourcesOut/Shader");
+ // 閫氳繃 tag 鎵惧埌 shader bundle 鍐呬换鎰忎竴涓湁鏁堝湴鍧�
+ var infos = YooAssetService.Instance.GetAssetInfosByTag("shader");
+ if (infos != null && infos.Length > 0)
+ {
+ // PackDirectory锛氭墍鏈� shader 鍦ㄥ悓涓� bundle锛屼紶浠绘剰鍦板潃鍗冲彲鍔犺浇鏁村寘
+ await YooAssetService.Instance.LoadAllAssetsAsync<Shader>(infos[0].Address);
+ }
+ else
+ {
+ Debug.LogWarning("[ShaderUtility] No asset infos found for tag 'shader'. " +
+ "Please set Asset Tags = 'shader' on the Shader collector in YooAsset and rebuild AB.");
+ }
}
+#if !UNITY_EDITOR
Shader.WarmupAllShaders();
+#endif
}
--
Gitblit v1.8.0