HKI Core
PlaySoundOnlyIfTimePassed.cs
Go to the documentation of this file.
1 using UnityEngine;
2 using System.Collections;
3 
4 namespace HKI.Core.Audio
5 {
9  public class PlaySoundOnlyIfTimePassed : MonoBehaviour
10  {
11  // Public variables
12  [SerializeField] PlaySoundClip PlaySoundClip = null;
13 
14  [SerializeField] float TimeToPass = 5.0f;
15 
16  // Private variables
17  bool playable = true;
18 
19  // Interface function
20  public void Play()
21  {
22  if (PlaySoundClip != null && playable)
23  {
24  PlaySoundClip.Play();
25  playable = false;
26  Invoke("ChangePlayableBack", TimeToPass);
27  }
28  }
29 
30  // Helper functions
32  {
33  playable = true;
34  }
35  }
36 }
This MonoBehaviour allows playing of a SoundClip on one of the general purpose AudioPlayers.
Definition: PlaySoundClip.cs:8
This MonoBehaviour allows the delay of playing a soundclip.