Browse Source

Null pointer check

master
Chris Gregan 9 years ago
parent
commit
39ed52499a
  1. 5
      Assets/Fungus/UI/Scripts/WriterAudio.cs

5
Assets/Fungus/UI/Scripts/WriterAudio.cs

@ -231,17 +231,20 @@ namespace Fungus
if (nextBeepTime < Time.realtimeSinceStartup) if (nextBeepTime < Time.realtimeSinceStartup)
{ {
targetAudioSource.clip = beepSounds[Random.Range(0, beepSounds.Count - 1)]; targetAudioSource.clip = beepSounds[Random.Range(0, beepSounds.Count - 1)];
if (targetAudioSource.clip != null)
{
targetAudioSource.loop = false; targetAudioSource.loop = false;
targetVolume = volume; targetVolume = volume;
targetAudioSource.Play(); targetAudioSource.Play();
float extend = targetAudioSource.clip.length; float extend = targetAudioSource.clip.length;
nextBeepTime = Time.realtimeSinceStartup + extend; nextBeepTime = Time.realtimeSinceStartup + extend;
} }
} }
} }
} }
} }
}
} }
Loading…
Cancel
Save