Browse Source

Fixed Writer beep timing issues in WebGL #295

master
chrisgregan 10 years ago
parent
commit
13f1aaa161
  1. 17
      Assets/Fungus/UI/Scripts/WriterAudio.cs

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

@ -46,6 +46,9 @@ namespace Fungus
// True when a voiceover clip is playing // True when a voiceover clip is playing
protected bool playingVoiceover = false; protected bool playingVoiceover = false;
// Time when current beep will have finished playing
protected float nextBeepTime;
public virtual void SetAudioMode(AudioMode mode) public virtual void SetAudioMode(AudioMode mode)
{ {
audioMode = mode; audioMode = mode;
@ -222,9 +225,17 @@ namespace Fungus
{ {
if (!targetAudioSource.isPlaying) if (!targetAudioSource.isPlaying)
{ {
targetAudioSource.clip = beepSounds[Random.Range(0, beepSounds.Count - 1)]; if (nextBeepTime < Time.realtimeSinceStartup)
targetAudioSource.loop = false; {
targetAudioSource.Play(); targetAudioSource.clip = beepSounds[Random.Range(0, beepSounds.Count - 1)];
targetAudioSource.loop = false;
targetVolume = volume;
targetAudioSource.Play();
float extend = targetAudioSource.clip.length;
nextBeepTime = Time.realtimeSinceStartup + extend;
}
} }
} }
} }

Loading…
Cancel
Save