Playlist
A Playlist is an instance that plays a sequence of music tracks in order, one after another. It’s ideal for ambient radio-style music or any scenario where you want continuous, automatic track changes. Use the music tracks you’ve already created in the Audio Creator window under the Music tab.
🛠️ How to create a Playlist
Playlist
Group your previously created tracks by their tags or by the Track
enum. For example, to set up a radio with three songs:
new Playlist("RockSong", "JazzSong", "ElectronicSong").Play();
Or using the Track
identifiers directly:
new Playlist(Track.RockSong, Track.JazzSong, Track.ElectronicSong).Play();
Playlist radio = new Playlist(Track.RockSong, Track.JazzSong)
.SetLoop(true) // Repeat the sequence when it ends
.SetFadeOut(1f); // 1-second fade-out at the end of each track
radio.Play();
📝 Advanced Example
Playlist ambientRadio = new Playlist(Track.ForestTheme, Track.RainTheme, Track.CityTheme)
.SetVolume(0.6f)
.SetLoop(true)
.SetFollowTarget(carTransform) // Music follows the car
.Shuffle() // Randomize track order
.SetOutput(Output.Music) // Route to the Music channel
.SetFadeIn(2f) // 2-second fade-in at the start of each track
.SetFadeOut(2f) // 2-second fade-out at the end of each track
.OnNextTrackStart(() => Debug.Log("Track changed!"))
.Play();
👉 Configures an “ambient radio” that shuffles tracks with smooth transitions and logs a message whenever the next song starts.
Last updated