From 39ed52499a37f304e8a2903c7f62f602f715b89e Mon Sep 17 00:00:00 2001 From: Chris Gregan Date: Sat, 14 May 2016 23:03:09 +0100 Subject: [PATCH] Null pointer check --- Assets/Fungus/UI/Scripts/WriterAudio.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Assets/Fungus/UI/Scripts/WriterAudio.cs b/Assets/Fungus/UI/Scripts/WriterAudio.cs index 25c61484..8f09720d 100644 --- a/Assets/Fungus/UI/Scripts/WriterAudio.cs +++ b/Assets/Fungus/UI/Scripts/WriterAudio.cs @@ -231,13 +231,16 @@ namespace Fungus if (nextBeepTime < Time.realtimeSinceStartup) { targetAudioSource.clip = beepSounds[Random.Range(0, beepSounds.Count - 1)]; - targetAudioSource.loop = false; - targetVolume = volume; - targetAudioSource.Play(); - float extend = targetAudioSource.clip.length; + if (targetAudioSource.clip != null) + { + targetAudioSource.loop = false; + targetVolume = volume; + targetAudioSource.Play(); - nextBeepTime = Time.realtimeSinceStartup + extend; + float extend = targetAudioSource.clip.length; + nextBeepTime = Time.realtimeSinceStartup + extend; + } } } }