public void PlaySong(int indexToPlay) { audioInterface.SetClip(playlist[indexToPlay]); StartCoroutine(WaitForSongEnd(audioInterface.GetClip().length)); audioInterface.Play(); playingIndex = indexToPlay; }
void OnCollisionEnter(Collision col) { float newVolume = Mathf.Clamp01(col.relativeVelocity.magnitude * collisionVolume); audioInterface.SetVolume(newVolume); audioInterface.SetClip(sourceClips[Random.Range(0, sourceClips.Length - 1)]); if (ignoreGroupForCollisions) { audioInterface.ForcePlay(); } else { audioInterface.Play(); } }
void Start() { audioInterface = GetComponent <AudioSourceInterface>(); #region Tests if (audioInterface.audioSource.playOnAwake) { Debug.LogWarning("Audio source for play once handler is set to play on awake. This is probably unintentional."); } #endregion //Option clip override. if (sourceClip != null) { audioInterface.SetClip(sourceClip); } }