feat: migrate setting centralize to haptic system.

This commit is contained in:
2026-05-14 20:42:21 +08:00
parent 10fa82bdce
commit fa4fd67d98
10 changed files with 138 additions and 16 deletions
@@ -13,13 +13,14 @@ namespace OCES.Haptic
public bool IsHapticSupported;
[NonSerialized]
public bool IsMeetsAdvanceRequirements;
[SerializeField]
HapticSettings hapticSettings;
internal ResourceLoader ResourceLoader;
HapticObjectConfig m_hapticObjects;
const string k_hapticConfigPath = "HapticData/";
const string k_hapticResourcesPath = "Haptics/";
public void Play(uint hapticId, bool isDirectCall = true)
{
HapticObject hapticObject = this.m_hapticObjects.QueryById(hapticId);
@@ -105,6 +106,8 @@ namespace OCES.Haptic
void Awake()
{
HapticSettings.Instance = this.hapticSettings;
if (Instance && Instance != this)
{
Destroy(gameObject);
@@ -115,14 +118,14 @@ namespace OCES.Haptic
this.ResourceLoader = gameObject.AddComponent<ResourceLoader>();
this.m_hapticObjects = HapticConfigLoader.Load<HapticObjectConfig>(k_hapticConfigPath + "HapticObject");
this.m_hapticObjects = HapticConfigLoader.Load<HapticObjectConfig>(HapticSettings.Instance.hapticConfigPath + "HapticObject");
this.IsHapticSupported = DeviceCapabilities.isVersionSupported;
this.IsMeetsAdvanceRequirements = DeviceCapabilities.meetsAdvancedRequirements;
}
static HapticClip GetHapticClip(HapticObject hapticObject)
{
return Instance.ResourceLoader.LoadSync<HapticClip>(k_hapticResourcesPath + hapticObject.Payload);
return Instance.ResourceLoader.LoadSync<HapticClip>(HapticSettings.Instance.hapticResourcePath + hapticObject.Payload);
}
static class HapticConfigLoader