public void ChangeMusicState(MusicState newState, bool restartOldClip = false, bool restartAllClips = false) { if (restartAllClips) { foreach (MusicSimple audioS in clips) { audioS.currentTime = 0; } } //Restart or pause old audio clip? if (restartOldClip) { currentMusicClip.currentTime = 0; } else { currentMusicClip.currentTime = source.time; } //Change audio state MusicSimple aS = clips.Find(item => item.audioState == newState); SetCurrentMusicClip(aS); source.Play(); }
public void SetCurrentMusicClip(MusicSimple newClip) { currentMusicClip = newClip; source.clip = currentMusicClip.audioClip; source.time = currentMusicClip.currentTime; }