feat():完成屏幕故障的音效添加

This commit is contained in:
2025-10-29 17:08:56 +08:00
parent 3c438b3871
commit 383121ab52
2 changed files with 106 additions and 0 deletions

View File

@@ -17,6 +17,9 @@ namespace Script.Gameplay.Global
[Tooltip("要控制的 RendererFeature 名称")] public string featureName = "ScreenGlitchFeature";
[SerializeField] private float glitchDuration = 1f;
[SerializeField] private AudioSource GlitchSoundSource;
[SerializeField] private AudioClip GlitchSoundClip;
public void SetFeatureActive(bool active)
{
if (rendererData == null)
@@ -42,6 +45,10 @@ namespace Script.Gameplay.Global
public IEnumerator TriggerGlitchEffect()
{
SetFeatureActive(true);
if (GlitchSoundSource != null && GlitchSoundClip != null)
{
GlitchSoundSource.PlayOneShot(GlitchSoundClip);
}
yield return new WaitForSeconds(glitchDuration);
SetFeatureActive(false);
}