feat: Unified ResourceLoader

- 新增 统一 `ResourceLoader`类,负责同步/异步加载资源,并对已加载的资源缓存。
- 修改 `MusicTransition`, `AudioSystem`, `LongAudioContainerPlayer`, `MusicSegment`, 'SfxSystem`, `HapticSystem`使用最新的`ResourceLoader`。
This commit is contained in:
2026-05-14 11:35:38 +08:00
parent 42d37512ed
commit 1df0666c91
7 changed files with 116 additions and 7 deletions
@@ -18,6 +18,8 @@ namespace OCES.Audio
public IReadOnlyDictionary<Type, Enum> ActiveStates { get; private set; }
public enum ConsoleLogLevel { Off, Log, Warning, Error } //TODO 实现这个功能
internal ResourceLoader ResourceLoader;
const string k_audioConfigPath = "AudioData";
const string k_audioResourcePath = "Audios";
@@ -29,6 +31,7 @@ namespace OCES.Audio
AudioMixer m_mixer;
Tween m_lowpassTween;
// ─────────────────────────────────────────────
// 公开接口
// ─────────────────────────────────────────────
@@ -279,8 +282,10 @@ namespace OCES.Audio
}
Instance = this;
DontDestroyOnLoad(gameObject);
this.ResourceLoader = gameObject.AddComponent<ResourceLoader>();
this.m_mixer = Resources.Load<AudioMixer>("Audios/Master");
this.m_mixer = this.ResourceLoader.LoadSync<AudioMixer>("Audios/Master");
// ── SFX 调度器 ──
// AudioSystem.cs 中
@@ -409,9 +414,13 @@ namespace OCES.Audio
public static T Load<T>(string tableName) where T : IBinarySerializable, new()
{
TextAsset bytes = Resources.Load<TextAsset>(tableName);
TextAsset bytes = AudioSystem.Instance.ResourceLoader.LoadSync<TextAsset>(tableName);
if (!bytes)
{
Debug.LogError($"未找到表 {tableName}");
return default;
}
IBinarySerializable data = new T();
bool readOk = FileManager.ReadBinaryDataFromBytes(bytes.bytes, ref data);
if (readOk)