yyl
2026-03-26 1ab047b5fdd933c38ba0519ec2e83a44512ea8d7
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 即可加载整包。
    /// 前提:Collector 的 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
    }