- Home /
make music continue play across scenes except one scenes
Hi, I have a question. I have an audio source attached to an object in main menu scene, and i wanted it's music to keep playing even when you are in some other scenes, EXCEPT FOR ONE SCENE, I WANT THAT SCENE TO PLAY DIFFRENT SONG.
For Example : In the MAIN MENU scene, The files audio called "main menu songs" is playing. In the MAIN MENU scene, i have 3 Button which it go through 3 different scenes : PLAY, HOW TO PLAY, & ABOUT US. When i clicks on HOW TO PLAY button and goes to HOW TO PLAY scene, the "main menu song" music is still playing.
When i back to MAIN MENU, and then i clicks on ABOUT US button and goes to ABOUT US scene, that "main menu songs" music is still playing until it finishes. As it has the loop, it plays again and again.
Then, in MAIN MENU, when i click on PLAY button and goes to PLAY scene. I want "main menu songs" stop playing, and change to another music playing (for example name audio files : stage songs).
I know its very hard, but has anyone know how to do this ? I don't have any idea of how to make this.
I SOLVE THE PROBLE$$anonymous$$.
CHEC$$anonymous$$ THIS OUT : https://answers.unity.com/questions/1253516/playing-audio-through-multiple-scenes.html
THAN$$anonymous$$ YOU SO $$anonymous$$UCH, @YoYoYoYo_111_PiPi .
Answer by Marioooo · Nov 26, 2019 at 08:18 PM
if you are using a single Scene structure for each part of the main menu (which is not a good practice, you could simply use 3 Panel objects and disable them depending on if you are in the main menu, or about us...)
Just create a prefab of the gameobject containing the music you want, then for each scene just drag that prefab and drag into the sound component the track you need... Voila!
you'll have 3 scenes and 3 different songs put into each gameobject
hope it helps!