Browse Source

Changed DialogAudio to be a component

master
chrisgregan 10 years ago
parent
commit
640c6a58fd
  1. 4
      Assets/Fungus/Narrative/Scripts/DialogAudio.cs
  2. 20
      Assets/Fungus/Narrative/Scripts/SayDialog.cs

4
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 AudioSource audioSource;
public AudioClip audioClip; public AudioClip audioClip;

20
Assets/Fungus/Narrative/Scripts/SayDialog.cs

@ -23,10 +23,10 @@ namespace Fungus
public Text storyText; public Text storyText;
public Image characterImage; public Image characterImage;
public DialogAudio audioController = new DialogAudio(); protected DialogAudio dialogAudio;
protected Writer writer; protected Writer writer;
protected CanvasGroup canvasGroup; protected CanvasGroup canvasGroup;
protected bool fadeWhenDone = true; protected bool fadeWhenDone = true;
protected float targetAlpha = 0f; protected float targetAlpha = 0f;
protected float fadeCoolDownTimer = 0f; protected float fadeCoolDownTimer = 0f;
@ -91,6 +91,22 @@ namespace Fungus
return canvasGroup; return canvasGroup;
} }
protected DialogAudio GetDialogAudio()
{
if (dialogAudio != null)
{
return dialogAudio;
}
dialogAudio = GetComponent<DialogAudio>();
if (dialogAudio == null)
{
dialogAudio = gameObject.AddComponent<DialogAudio>();
}
return dialogAudio;
}
protected void Start() protected void Start()
{ {
// Dialog always starts invisible, will be faded in when writing starts // Dialog always starts invisible, will be faded in when writing starts

Loading…
Cancel
Save