Browse Source

Added waitUntilFinished property to Play Sound

master
chrisgregan 10 years ago
parent
commit
894308e2e8
  1. 21
      Assets/Fungus/Audio/Scripts/Commands/PlaySound.cs

21
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();
}

Loading…
Cancel
Save