void Update() { if (!MyTrack) { return; } if (audioState != AudioState.Playing) { return; } if (sources[0].time >= MyTrack.EndLoopTime) { audioState = AudioState.FadeToLoop; Loop(); } trackVolumesOutput = TrackVolumes.Lerp(trackVolumesOutput, trackVolumes, Time.deltaTime * trackVolumesLerpSpeed); UpdateAudioSourcesVolume(); }
/// <summary> /// Change the music zone I'm playing for. /// This ONLY supports swapping between zones that share the same track! /// </summary> public void ChangeZones(MusicZone newMusicZone, float newFadeTime = 1) { if (newMusicZone == musicZone) { return; } string oldName = musicZone ? musicZone.name : "null"; Debug.Log("Track " + MyTrack.name + " is changing zones from " + oldName + " to " + newMusicZone.name); if (newMusicZone.musicTrack != MyTrack) { Debug.LogError(name + " trying to change music zones, but the current and new zones don't " + "have the same tracks.", gameObject); return; } musicZone = newMusicZone; trackVolumes = newMusicZone.GenerateVolumes(); fadeInTime = newFadeTime; }
public TrackVolumes(TrackVolumes original) { volumes = new List <float>(original.volumes); }