Browse Source

Added TextTag WVO WaitForVoiceOver

Say has a Wait For VO flag to add wvo text tag like it does the wi tag
Added SayHolds demo scene to show how the combinations of waits interact
master
desktop-maesty/steve 7 years ago
parent
commit
fb5c174152
  1. 7
      Assets/Fungus/Scripts/Commands/Say.cs
  2. 4
      Assets/Fungus/Scripts/Commands/Write.cs
  3. 10
      Assets/Fungus/Scripts/Components/SayDialog.cs
  4. 30
      Assets/Fungus/Scripts/Components/Writer.cs
  5. 15
      Assets/Fungus/Scripts/Components/WriterAudio.cs
  6. 5
      Assets/Fungus/Scripts/Editor/SayEditor.cs
  7. 2
      Assets/Fungus/Scripts/Utils/ConversationManager.cs
  8. 6
      Assets/Fungus/Scripts/Utils/TextTagParser.cs
  9. 4
      Assets/Fungus/Scripts/Utils/TextTagToken.cs
  10. 9
      Assets/FungusExamples/SayHolds.meta
  11. 1092
      Assets/FungusExamples/SayHolds/SayHolds.unity
  12. 8
      Assets/FungusExamples/SayHolds/SayHolds.unity.meta
  13. BIN
      Assets/FungusExamples/SayHolds/VO1.mp3
  14. 23
      Assets/FungusExamples/SayHolds/VO1.mp3.meta
  15. BIN
      Assets/FungusExamples/SayHolds/VO2.mp3
  16. 23
      Assets/FungusExamples/SayHolds/VO2.mp3.meta
  17. BIN
      Assets/FungusExamples/SayHolds/VO3.mp3
  18. 23
      Assets/FungusExamples/SayHolds/VO3.mp3.meta
  19. 1
      Docs/command_ref/narrative_commands.md

7
Assets/Fungus/Scripts/Commands/Say.cs

@ -48,6 +48,11 @@ namespace Fungus
[Tooltip("Stop playing voiceover when text finishes writing.")]
[SerializeField] protected bool stopVoiceover = true;
[Tooltip("Wait for the Voice Over to complete before continuing")]
[SerializeField] protected bool waitForVO = false;
//add wait for vo that overrides stopvo
[Tooltip("Sets the active Say dialog with a reference to a Say Dialog object in the scene. All story text will now display using this Say Dialog.")]
[SerializeField] protected SayDialog setSayDialog;
@ -120,7 +125,7 @@ namespace Fungus
string subbedText = flowchart.SubstituteVariables(displayText);
sayDialog.Say(subbedText, !extendPrevious, waitForClick, fadeWhenDone, stopVoiceover, voiceOverClip, delegate {
sayDialog.Say(subbedText, !extendPrevious, waitForClick, fadeWhenDone, stopVoiceover, waitForVO, voiceOverClip, delegate {
Continue();
});
}

4
Assets/Fungus/Scripts/Commands/Write.cs

@ -99,12 +99,12 @@ namespace Fungus
if (!waitUntilFinished)
{
StartCoroutine(writer.Write(newText, clearText, false, true, null, null));
StartCoroutine(writer.Write(newText, clearText, false, true, false, null, null));
Continue();
}
else
{
StartCoroutine(writer.Write(newText, clearText, false, true, null,
StartCoroutine(writer.Write(newText, clearText, false, true, false, null,
() => { Continue (); }
));
}

10
Assets/Fungus/Scripts/Components/SayDialog.cs

@ -427,9 +427,9 @@ namespace Fungus
/// <param name="stopVoiceover">Stop any existing voiceover audio before writing starts.</param>
/// <param name="voiceOverClip">Voice over audio clip to play.</param>
/// <param name="onComplete">Callback to execute when writing and player input have finished.</param>
public virtual void Say(string text, bool clearPrevious, bool waitForInput, bool fadeWhenDone, bool stopVoiceover, AudioClip voiceOverClip, Action onComplete)
public virtual void Say(string text, bool clearPrevious, bool waitForInput, bool fadeWhenDone, bool stopVoiceover, bool waitForVO, AudioClip voiceOverClip, Action onComplete)
{
StartCoroutine(DoSay(text, clearPrevious, waitForInput, fadeWhenDone, stopVoiceover, voiceOverClip, onComplete));
StartCoroutine(DoSay(text, clearPrevious, waitForInput, fadeWhenDone, stopVoiceover, waitForVO, voiceOverClip, onComplete));
}
/// <summary>
@ -442,7 +442,7 @@ namespace Fungus
/// <param name="stopVoiceover">Stop any existing voiceover audio before writing starts.</param>
/// <param name="voiceOverClip">Voice over audio clip to play.</param>
/// <param name="onComplete">Callback to execute when writing and player input have finished.</param>
public virtual IEnumerator DoSay(string text, bool clearPrevious, bool waitForInput, bool fadeWhenDone, bool stopVoiceover, AudioClip voiceOverClip, Action onComplete)
public virtual IEnumerator DoSay(string text, bool clearPrevious, bool waitForInput, bool fadeWhenDone, bool stopVoiceover, bool waitForVO, AudioClip voiceOverClip, Action onComplete)
{
var writer = GetWriter();
@ -483,7 +483,9 @@ namespace Fungus
soundEffectClip = speakingCharacter.SoundEffect;
}
yield return StartCoroutine(writer.Write(text, clearPrevious, waitForInput, stopVoiceover, soundEffectClip, onComplete));
writer.AttachedWriterAudio = writerAudio;
yield return StartCoroutine(writer.Write(text, clearPrevious, waitForInput, stopVoiceover, waitForVO, soundEffectClip, onComplete));
}
/// <summary>

30
Assets/Fungus/Scripts/Components/Writer.cs

@ -93,6 +93,7 @@ namespace Fungus
protected string hiddenColorClose = "";
protected int visibleCharacterCount = 0;
public WriterAudio AttachedWriterAudio { get; set; }
protected virtual void Awake()
{
@ -347,8 +348,12 @@ namespace Fungus
case TokenType.WaitForInputAndClear:
yield return StartCoroutine(DoWaitForInput(true));
break;
case TokenType.WaitOnPunctuationStart:
case TokenType.WaitForVoiceOver:
yield return StartCoroutine(DoWaitVO());
break;
case TokenType.WaitOnPunctuationStart:
TryGetSingleParam(token.paramList, 0, punctuationPause, out currentPunctuationPause);
break;
@ -654,6 +659,18 @@ namespace Fungus
yield return StartCoroutine( DoWait(duration) );
}
protected virtual IEnumerator DoWaitVO()
{
float duration = 0f;
if (AttachedWriterAudio != null)
{
duration = AttachedWriterAudio.GetSecondsRemaining();
}
yield return StartCoroutine(DoWait(duration));
}
protected virtual IEnumerator DoWait(float duration)
{
NotifyPause();
@ -892,9 +909,10 @@ namespace Fungus
/// <param name="clear">If true clears the previous text.</param>
/// <param name="waitForInput">Writes the text and then waits for player input before calling onComplete.</param>
/// <param name="stopAudio">Stops any currently playing audioclip.</param>
/// <param name="waitForVO">Wait for the Voice over to complete before proceeding</param>
/// <param name="audioClip">Audio clip to play when text starts writing.</param>
/// <param name="onComplete">Callback to call when writing is finished.</param>
public virtual IEnumerator Write(string content, bool clear, bool waitForInput, bool stopAudio, AudioClip audioClip, Action onComplete)
public virtual IEnumerator Write(string content, bool clear, bool waitForInput, bool stopAudio, bool waitForVO, AudioClip audioClip, Action onComplete)
{
if (clear)
{
@ -916,6 +934,12 @@ namespace Fungus
tokenText += "{wi}";
}
if(waitForVO)
{
tokenText += "{wvo}";
}
List<TextTagToken> tokens = TextTagParser.Tokenize(tokenText);
gameObject.SetActive(true);

15
Assets/Fungus/Scripts/Components/WriterAudio.cs

@ -53,9 +53,24 @@ namespace Fungus
// True when a voiceover clip is playing
protected bool playingVoiceover = false;
public bool IsPlayingVoiceOver { get { return playingVoiceover; } }
// Time when current beep will have finished playing
protected float nextBeepTime;
public float GetSecondsRemaining()
{
if (IsPlayingVoiceOver)
{
return targetAudioSource.clip.length - targetAudioSource.time;
}
else
{
return 0F;
}
}
protected virtual void SetAudioMode(AudioMode mode)
{
audioMode = mode;

5
Assets/Fungus/Scripts/Editor/SayEditor.cs

@ -81,6 +81,7 @@ namespace Fungus.EditorUtils
protected SerializedProperty waitForClickProp;
protected SerializedProperty stopVoiceoverProp;
protected SerializedProperty setSayDialogProp;
protected SerializedProperty waitForVOProp;
protected virtual void OnEnable()
{
@ -99,6 +100,7 @@ namespace Fungus.EditorUtils
waitForClickProp = serializedObject.FindProperty("waitForClick");
stopVoiceoverProp = serializedObject.FindProperty("stopVoiceover");
setSayDialogProp = serializedObject.FindProperty("setSayDialog");
waitForVOProp = serializedObject.FindProperty("waitForVO");
if (blackTex == null)
{
@ -197,7 +199,8 @@ namespace Fungus.EditorUtils
EditorGUILayout.PropertyField(waitForClickProp);
EditorGUILayout.PropertyField(stopVoiceoverProp);
EditorGUILayout.PropertyField(setSayDialogProp);
EditorGUILayout.PropertyField(waitForVOProp);
if (showPortraits && t.Portrait != null)
{
Texture2D characterTexture = t.Portrait.texture;

2
Assets/Fungus/Scripts/Utils/ConversationManager.cs

@ -380,7 +380,7 @@ namespace Fungus
if (!string.IsNullOrEmpty(item.Text)) {
exitSayWait = false;
sayDialog.Say(item.Text, true, true, true, true, null, () => {
sayDialog.Say(item.Text, true, true, true, true, false, null, () => {
exitSayWait = true;
});

6
Assets/Fungus/Scripts/Utils/TextTagParser.cs

@ -71,10 +71,14 @@ namespace Fungus
{
type = TokenType.WaitForInputNoClear;
}
if (tag == "wc")
else if (tag == "wc")
{
type = TokenType.WaitForInputAndClear;
}
else if (tag == "wvo")
{
type = TokenType.WaitForVoiceOver;
}
else if (tag.StartsWith("wp="))
{
type = TokenType.WaitOnPunctuationStart;

4
Assets/Fungus/Scripts/Utils/TextTagToken.cs

@ -65,7 +65,9 @@ namespace Fungus
/// <summary> audiopause=Sound </summary>
AudioPause,
/// <summary> audiostop=Sound </summary>
AudioStop
AudioStop,
/// <summary> wvo </summary>
WaitForVoiceOver,
}
/// <summary>

9
Assets/FungusExamples/SayHolds.meta

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 667834e9d0ed9f647aa23c2e7f762608
folderAsset: yes
timeCreated: 1507112341
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

1092
Assets/FungusExamples/SayHolds/SayHolds.unity

File diff suppressed because it is too large Load Diff

8
Assets/FungusExamples/SayHolds/SayHolds.unity.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cf49e1fbc6d734643b3df6acf28c19a5
timeCreated: 1507112342
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/FungusExamples/SayHolds/VO1.mp3

Binary file not shown.

23
Assets/FungusExamples/SayHolds/VO1.mp3.meta

@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: bcc782f50f1c67842a7b10f1a4a68959
timeCreated: 1507114363
licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/FungusExamples/SayHolds/VO2.mp3

Binary file not shown.

23
Assets/FungusExamples/SayHolds/VO2.mp3.meta

@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: d389acad13a64274fa4f6c67282b8c8e
timeCreated: 1507114363
licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/FungusExamples/SayHolds/VO3.mp3

Binary file not shown.

23
Assets/FungusExamples/SayHolds/VO3.mp3.meta

@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: f995fd20bd1b22c4083a882ea47ae695
timeCreated: 1507114363
licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

1
Docs/command_ref/narrative_commands.md

@ -105,6 +105,7 @@ Fade When Done | System.Boolean | Fade out the dialog box when writing has finis
Wait For Click | System.Boolean | Wait for player to click before continuing.
Stop Voiceover | System.Boolean | Stop playing voiceover when text finishes writing.
Set Say Dialog | Fungus.SayDialog | Sets the active Say dialog with a reference to a Say Dialog object in the scene. All story text will now display using this Say Dialog.
Wait for VO | System.Boolean | Wait for the VO line to complete before continuing.
# Set Language # {#SetLanguage}
Set the active language for the scene. A Localization object with a localization file must be present in the scene.

Loading…
Cancel
Save