yyl
2026-02-12 5667c0a5e6b83964e2538a17dcfd6b719692ddda
Main/ResModule/ResManager.cs
@@ -388,29 +388,35 @@
    /// <summary>
    /// 异步加载配置文件(UniTask 版本)。
    /// WebGL 平台使用 YooAsset RawFile 异步加载,其他平台使用线程池。
    /// AB 模式使用 YooAsset RawFile 异步加载,非 AB 模式直接读文件。
    /// </summary>
    public async UniTask<string[]> LoadConfigAsync(string name, CancellationToken ct = default)
    {
#if UNITY_WEBGL && !UNITY_EDITOR
        // WebGL 不支持多线程和 File.ReadAllLines,使用 YooAsset RawFile
        try
        // AB 模式(含 WebGL): 使用 YooAsset RawFile 加载(配置文件在 YooAsset 沙盒中)
        if (AssetSource.isUseAssetBundle)
        {
            var text = await ProjSG.Resource.YooAssetService.Instance.LoadRawFileTextAsync($"config/{name}", ct);
            if (!string.IsNullOrEmpty(text))
            try
            {
                return text.Split(new[] { "\r\n", "\n" }, System.StringSplitOptions.None);
                var location = $"Assets/ResourcesOut/Config/{name}.txt";
                var text = await ProjSG.Resource.YooAssetService.Instance.LoadRawFileTextAsync(location, ct);
                if (!string.IsNullOrEmpty(text))
                {
                    return text.Split(new[] { "\r\n", "\n" }, System.StringSplitOptions.None);
                }
            }
            catch (System.Exception ex)
            {
                UnityEngine.Debug.LogError($"[ResManager] LoadConfigAsync YooAsset failed for '{name}': {ex.Message}");
            }
            return System.Array.Empty<string>();
        }
        catch (System.Exception ex)
        {
            UnityEngine.Debug.LogError($"[ResManager] LoadConfigAsync WebGL fallback failed for '{name}': {ex.Message}");
        }
        return System.Array.Empty<string>();
        // 非 AB 模式: 直接读文件(Editor 开发模式)
#if UNITY_EDITOR
        string path = ResourcesPath.CONFIG_FODLER + "/" + name + ".txt";
        return await UniTask.RunOnThreadPool(() => File.ReadAllLines(path));
#else
        #pragma warning disable CS0618 // LoadConfig is obsolete — used here as thread-pool fallback for non-WebGL
        return await UniTask.RunOnThreadPool(() => LoadConfig(name));
        #pragma warning restore CS0618
        return System.Array.Empty<string>();
#endif
    }