diff --git a/Assets/Fungus/Narrative/Scripts/DialogAudio.cs b/Assets/Fungus/Narrative/Scripts/DialogAudio.cs index 89abcb93..54327c35 100644 --- a/Assets/Fungus/Narrative/Scripts/DialogAudio.cs +++ b/Assets/Fungus/Narrative/Scripts/DialogAudio.cs @@ -5,9 +5,9 @@ namespace Fungus { /* - * Helper class to manage play, pause & stop operations on voiceover and writing sound effects + * Manages audio effects for Dialogs */ - public class DialogAudio + public class DialogAudio : MonoBehaviour { public AudioSource audioSource; public AudioClip audioClip; diff --git a/Assets/Fungus/Narrative/Scripts/SayDialog.cs b/Assets/Fungus/Narrative/Scripts/SayDialog.cs index 769f063a..c726a298 100644 --- a/Assets/Fungus/Narrative/Scripts/SayDialog.cs +++ b/Assets/Fungus/Narrative/Scripts/SayDialog.cs @@ -23,10 +23,10 @@ namespace Fungus public Text storyText; public Image characterImage; - public DialogAudio audioController = new DialogAudio(); - + protected DialogAudio dialogAudio; protected Writer writer; protected CanvasGroup canvasGroup; + protected bool fadeWhenDone = true; protected float targetAlpha = 0f; protected float fadeCoolDownTimer = 0f; @@ -91,6 +91,22 @@ namespace Fungus return canvasGroup; } + protected DialogAudio GetDialogAudio() + { + if (dialogAudio != null) + { + return dialogAudio; + } + + dialogAudio = GetComponent(); + if (dialogAudio == null) + { + dialogAudio = gameObject.AddComponent(); + } + + return dialogAudio; + } + protected void Start() { // Dialog always starts invisible, will be faded in when writing starts