diff --git a/Assets/Fungus/Audio/Scripts/Commands/PlaySound.cs b/Assets/Fungus/Audio/Scripts/Commands/PlaySound.cs index 9bf3382d..09e8c75c 100644 --- a/Assets/Fungus/Audio/Scripts/Commands/PlaySound.cs +++ b/Assets/Fungus/Audio/Scripts/Commands/PlaySound.cs @@ -16,14 +16,35 @@ namespace Fungus [Tooltip("Volume level of the sound effect")] public float volume = 1; + [Tooltip("Wait until the sound has finished playing before continuing execution.")] + public bool waitUntilFinished; + public override void OnEnter() { + if (soundClip == null) + { + Continue(); + return; + } + MusicController musicController = MusicController.GetInstance(); if (musicController != null) { musicController.PlaySound(soundClip, volume); } + if (waitUntilFinished) + { + Invoke("DoWait", soundClip.length); + } + else + { + Continue(); + } + } + + protected virtual void DoWait() + { Continue(); }