Browse Source

Voice over is now cancelled when story progresses to next line

master
chrisgregan 10 years ago
parent
commit
03047fc17f
  1. 2
      Assets/Fungus/Dialog/Scripts/Commands/Choose.cs
  2. 2
      Assets/Fungus/Dialog/Scripts/Commands/Say.cs
  3. 21
      Assets/Fungus/Dialog/Scripts/Dialog.cs
  4. 3
      Assets/Fungus/Dialog/Scripts/SayDialog.cs

2
Assets/Fungus/Dialog/Scripts/Commands/Choose.cs

@ -98,7 +98,7 @@ namespace Fungus
if (voiceOverClip != null)
{
MusicController.GetInstance().PlaySound(voiceOverClip, 1f);
chooseDialog.PlayVoiceOver(voiceOverClip);
}
chooseDialog.Choose(chooseText, dialogOptions, timeoutDuration, delegate {

2
Assets/Fungus/Dialog/Scripts/Commands/Say.cs

@ -60,7 +60,7 @@ namespace Fungus
if (voiceOverClip != null)
{
MusicController.GetInstance().PlaySound(voiceOverClip, 1f);
sayDialog.PlayVoiceOver(voiceOverClip);
}
sayDialog.Say(storyText, delegate {

21
Assets/Fungus/Dialog/Scripts/Dialog.cs

@ -34,6 +34,8 @@ namespace Fungus
protected bool wasPointerClicked;
protected AudioSource voiceOverAudio;
protected virtual void LateUpdate()
{
wasPointerClicked = false;
@ -210,6 +212,7 @@ namespace Fungus
OnWaitForInputTag(false);
currentSpeed = writingSpeed;
dialogText.Clear();
StopVoiceOver();
break;
case TokenType.WaitOnPunctuation:
@ -332,6 +335,24 @@ namespace Fungus
wasPointerClicked = true;
}
}
public virtual void PlayVoiceOver(AudioClip voiceOverSound)
{
if (voiceOverAudio == null)
{
voiceOverAudio = gameObject.AddComponent<AudioSource>();
}
voiceOverAudio.clip = voiceOverSound;
voiceOverAudio.Play();
}
public virtual void StopVoiceOver()
{
if (voiceOverAudio)
{
Destroy(voiceOverAudio);
}
}
}
}

3
Assets/Fungus/Dialog/Scripts/SayDialog.cs

@ -39,7 +39,8 @@ namespace Fungus
Action onWritingComplete = delegate {
ShowContinueImage(true);
StartCoroutine(WaitForInput(delegate {
Clear();
Clear();
StopVoiceOver();
if (onComplete != null)
{
onComplete();

Loading…
Cancel
Save