feat: 音效、音量、触感开关控制

This commit is contained in:
2026-05-22 20:40:35 +08:00
parent 669fdea58c
commit cf5a2ba2c2
3 changed files with 33 additions and 0 deletions
@@ -127,6 +127,27 @@ namespace OCES.Audio
).SetEase(Ease.OutCubic);
}
public void SetMusicVolume(float targetVolume)
{
this.m_mixer.SetFloat("MusicVolume", targetVolume);
}
public void SetSFXVolume(float targetVolume)
{
this.m_mixer.SetFloat("SFXVolume", targetVolume);
this.m_mixer.SetFloat("SFXAccentVolume", targetVolume);
}
public void SetMusicState(bool enable)
{
SetMusicVolume(enable ? 0 : -80);
}
public void SetSFXState(bool enable)
{
SetSFXVolume(enable ? 0 : -80);
}
/// <summary>
/// 更新游戏状态,驱动音乐与环境音系统切换。
/// 调用示例:AudioSystem.Instance.SetState(GameState.Game);
@@ -104,6 +104,11 @@ namespace OCES.Haptic
{
HapticController.Stop();
}
public void EnableHaptic(bool enable)
{
HapticController.hapticsEnabled = enable;
}
void Awake()
{