Is it possible to have mulitple soundtracks on a game?

Similar to when the voice in Black Ops 2 Zombies when the guy talks and then the music starts to play. Or when one soundtrack ends, another one starts and so on and so forth. No I do not mean to loop any track. Its more so like a radio type of effect that I want to have where songs just constantly keep playing and if possible for them to shuffle and repeat all. I’m not the best at coding so I could use a code for it. Thanks

yes it can, You have to use some UI buttons for it and create a script and add those component by making array its pretty much easy.

I think the term you need to search for is “jukebox”, which would lead you to something like http://wiki.unity3d.com/index.php/JukeboxController

(Answer by aldonaletto · Nov 04, 2013 at 10:52 PM)

First of all, add an AudioSource component to the object via menu Component/Audio/Audio Source, and delete the AudioSource declaration in your code (audio is a GameObject property). Change also the declaration of myMusic to Object (that’s what LoadAll returns), and don’t initialize it (there’s no need). Finally, remove the type coercion from LoadAll (you can’t coerce type of entire arrays this way). The code would become this:

 using UnityEngine;
 using System.Collections;
  
 public class Music : MonoBehaviour {
  
     Object[] myMusic; // declare this as Object array
     
     void Awake () {
        myMusic = Resources.LoadAll("Music",typeof(AudioClip));
        audio.clip = myMusic[0] as AudioClip;
     }
     
     void Start (){
        audio.Play(); 
     }
  
     // Update is called once per frame
     void Update () {
        if(!audio.isPlaying)
          playRandomMusic();
     }
     
     void playRandomMusic() {
        audio.clip = myMusic[Random.Range(0,myMusic.Length)] as AudioClip;
        audio.Play();
     }
 }

NOTE: The audio clips must be inside a folder Resources/Music, or LoadAll won’t find them.