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 36f4c2e2d3
commit c30239111c
7 changed files with 116 additions and 7 deletions
@@ -13,6 +13,8 @@ namespace OCES.Haptic
public bool IsHapticSupported;
[NonSerialized]
public bool IsMeetsAdvanceRequirements;
internal ResourceLoader ResourceLoader;
HapticObjectConfig m_hapticObjects;
const string k_hapticConfigPath = "HapticData/";
@@ -110,6 +112,8 @@ namespace OCES.Haptic
}
Instance = this;
DontDestroyOnLoad(gameObject);
this.ResourceLoader = gameObject.AddComponent<ResourceLoader>();
this.m_hapticObjects = HapticConfigLoader.Load<HapticObjectConfig>(k_hapticConfigPath + "HapticObject");
this.IsHapticSupported = DeviceCapabilities.isVersionSupported;
@@ -118,16 +122,19 @@ namespace OCES.Haptic
static HapticClip GetHapticClip(HapticObject hapticObject)
{
return Resources.Load<HapticClip>(k_hapticResourcesPath + hapticObject.Payload);
return Instance.ResourceLoader.LoadSync<HapticClip>(k_hapticResourcesPath + hapticObject.Payload);
}
static class HapticConfigLoader
{
internal static T Load<T>(string tableName) where T : IBinarySerializable, new()
{
TextAsset bytes = Resources.Load<TextAsset>(tableName);
TextAsset bytes = 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)