So i have a menu on my 1st scene and if they click one of the buttons it leads them to another scene to level 1 , anyone know how i can pause the music from the first scene and turn on the second scene’s music? As well as if they die and go back to scene 1 the menu music turns on?
Thank You.
@Alima-1224 Make a game object and add a script to it. Name that script to Mucis_controler. Bow in that script add DontDestroyOnLoad(this.gameObject); in the start. This will not distory the game object when new scene loads.
Now all an audio source to this game object.
In you script add using unityengine.audio and using unityengine.scenemanagement.
Now add the refrence for audio source and audio clips.
public Audioclip ac; //in this arrar add the audip clip for different levels.
public AudioSource a_s;
In the update do a if check
if(SceneManager.getActiveScene().name == “level_name”){
a_s.clip = ac[0];
a_s.play();
}
//do this if for every level and set the desired audio clip.
hope this will solve your problem
PS : There might be some syntax mistake, so please dont copy, because I am writingvthis from mobile.