feat: 解耦音频与触感系统
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using OCES.Haptic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace OCES.Audio
|
||||
{
|
||||
public partial class AudioSystem
|
||||
{
|
||||
partial void OnAwakeComplete()
|
||||
{
|
||||
this.m_sfxSystem.OnSoundStarted += activeSound =>
|
||||
{
|
||||
uint hapticId = activeSound.AudioObject.Haptic;
|
||||
if (hapticId == 0) return;
|
||||
|
||||
if (activeSound.AudioObject.ContainerType == ContainerType.Blend && activeSound.AudioObject.Haptic > 0)
|
||||
{
|
||||
Debug.LogWarning($"[Haptic System] Blend container {activeSound.AudioObject.Id} should not have haptic feedback!");
|
||||
return;
|
||||
}
|
||||
|
||||
HapticSystem.Instance.Play(hapticId, isDirectCall: false);
|
||||
};
|
||||
|
||||
this.m_sfxSystem.OnSoundStopped += activeSound =>
|
||||
{
|
||||
uint hapticId = activeSound.AudioObject.Haptic;
|
||||
if (hapticId == 0) return;
|
||||
HapticSystem.Instance.Stop(hapticId);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user