diff --git a/Assets/Fungus/Narrative/Scripts/SayDialog.cs b/Assets/Fungus/Narrative/Scripts/SayDialog.cs
index 01bb550b..fda8059a 100644
--- a/Assets/Fungus/Narrative/Scripts/SayDialog.cs
+++ b/Assets/Fungus/Narrative/Scripts/SayDialog.cs
@@ -181,7 +181,7 @@ namespace Fungus
if (voiceOverClip != null)
{
WriterAudio writerAudio = GetWriterAudio();
- writerAudio.PlayVoiceover(voiceOverClip);
+ writerAudio.OnVoiceover(voiceOverClip);
}
else if (speakingCharacter != null)
{
diff --git a/Assets/Fungus/UI/Scripts/IWriter.cs b/Assets/Fungus/UI/Scripts/IWriter.cs
index 98c5127d..77b283c9 100644
--- a/Assets/Fungus/UI/Scripts/IWriter.cs
+++ b/Assets/Fungus/UI/Scripts/IWriter.cs
@@ -65,11 +65,16 @@ namespace Fungus
/// Called when the Writer has resumed writing text.
void OnResume();
- /// Called when the Writer has finshed writing text.
+ /// Called when the Writer has finished writing text.
/// Controls whether audio should be stopped when writing ends.
void OnEnd(bool stopAudio);
/// Called every time the Writer writes a new character glyph.
void OnGlyph();
+
+ ///
+ /// Called when voiceover should start.
+ ///
+ void OnVoiceover(AudioClip voiceOverClip);
}
}
\ No newline at end of file
diff --git a/Assets/Fungus/UI/Scripts/WriterAudio.cs b/Assets/Fungus/UI/Scripts/WriterAudio.cs
index 9c908329..399cb335 100644
--- a/Assets/Fungus/UI/Scripts/WriterAudio.cs
+++ b/Assets/Fungus/UI/Scripts/WriterAudio.cs
@@ -51,7 +51,7 @@ namespace Fungus
// Time when current beep will have finished playing
protected float nextBeepTime;
- public virtual void SetAudioMode(AudioMode mode)
+ protected virtual void SetAudioMode(AudioMode mode)
{
audioMode = mode;
}
@@ -71,29 +71,7 @@ namespace Fungus
targetAudioSource.volume = 0f;
}
- ///
- /// Plays a voiceover audio clip.
- /// Voiceover behaves differently than speaking sound effects because it
- /// should keep on playing after the text has finished writing. It also
- /// does not pause for wait tags, punctuation, etc.
- ///
- public virtual void PlayVoiceover(AudioClip voiceOverClip)
- {
- if (targetAudioSource == null)
- {
- return;
- }
-
- playingVoiceover = true;
-
- targetAudioSource.volume = volume;
- targetVolume = volume;
- targetAudioSource.loop = false;
- targetAudioSource.clip = voiceOverClip;
- targetAudioSource.Play();
- }
-
- public virtual void Play(AudioClip audioClip)
+ protected virtual void Play(AudioClip audioClip)
{
if (targetAudioSource == null ||
(audioMode == AudioMode.SoundEffect && soundEffect == null && audioClip == null) ||
@@ -130,7 +108,7 @@ namespace Fungus
}
}
- public virtual void Pause()
+ protected virtual void Pause()
{
if (targetAudioSource == null)
{
@@ -141,7 +119,7 @@ namespace Fungus
targetVolume = 0f;
}
- public virtual void Stop()
+ protected virtual void Stop()
{
if (targetAudioSource == null)
{
@@ -156,7 +134,7 @@ namespace Fungus
playingVoiceover = false;
}
- public virtual void Resume()
+ protected virtual void Resume()
{
if (targetAudioSource == null)
{
@@ -246,6 +224,22 @@ namespace Fungus
}
}
+ public virtual void OnVoiceover(AudioClip voiceOverClip)
+ {
+ if (targetAudioSource == null)
+ {
+ return;
+ }
+
+ playingVoiceover = true;
+
+ targetAudioSource.volume = volume;
+ targetVolume = volume;
+ targetAudioSource.loop = false;
+ targetAudioSource.clip = voiceOverClip;
+ targetAudioSource.Play();
+ }
+
#endregion
}
}
\ No newline at end of file