From 485140c1d18981c97c2598f99073a3422996bfa8 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Tue, 21 Oct 2014 16:00:37 +0100 Subject: [PATCH] Null pointer checks in case typing audio is not set --- Assets/Fungus/Dialog/Scripts/Dialog.cs | 32 +++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/Assets/Fungus/Dialog/Scripts/Dialog.cs b/Assets/Fungus/Dialog/Scripts/Dialog.cs index 1c7cc469..4b0c5231 100644 --- a/Assets/Fungus/Dialog/Scripts/Dialog.cs +++ b/Assets/Fungus/Dialog/Scripts/Dialog.cs @@ -249,9 +249,13 @@ namespace Fungus if (!skipCharacter) { - typingAudio.audio.Pause(); + if (typingAudio != null) + typingAudio.audio.Pause(); + yield return new WaitForSeconds(currentPunctuationPause); - typingAudio.audio.Play(); + + if (typingAudio != null) + typingAudio.audio.Play(); } } @@ -288,19 +292,27 @@ namespace Fungus { duration = 1f; } - typingAudio.audio.Pause(); + + if (typingAudio != null) + typingAudio.audio.Pause(); + yield return new WaitForSeconds(duration); - typingAudio.audio.Play(); + + if (typingAudio != null) + typingAudio.audio.Play(); timeAccumulator = 0f; break; case GlyphType.WaitForInputNoClear: OnWaitForInputTag(true); + if (typingAudio != null) + typingAudio.audio.Pause(); - typingAudio.audio.Pause(); yield return StartCoroutine(WaitForInput(null)); - typingAudio.audio.Play(); + + if (typingAudio != null) + typingAudio.audio.Play(); timeAccumulator = 0f; OnWaitForInputTag(false); @@ -309,9 +321,13 @@ namespace Fungus case GlyphType.WaitForInputAndClear: OnWaitForInputTag(true); - typingAudio.audio.Pause(); + if (typingAudio != null) + typingAudio.audio.Pause(); + yield return StartCoroutine(WaitForInput(null)); - typingAudio.audio.Play(); + + if (typingAudio != null) + typingAudio.audio.Play(); OnWaitForInputTag(false); timeAccumulator = 0f;