Browse Source

Merge pull request #296 from FungusGames/webgl-beep-timing-#295

Fixed Writer beep timing issues in WebGL #295
master
Chris Gregan 9 years ago
parent
commit
5ef2338bea
  1. 19
      Assets/Fungus/UI/Scripts/WriterAudio.cs

19
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;
@ -210,7 +213,7 @@ namespace Fungus
{ {
Stop(); Stop();
} }
public virtual void OnGlyph() public virtual void OnGlyph()
{ {
if (playingVoiceover) if (playingVoiceover)
@ -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