- Home /
Duplicate Question, in general; and by user : http://answers.unity3d.com/questions/878382/audio-or-music-to-continue-playing-between-scene.html
Audio or Music to continue playing between scene changes
Is there a simple way to have audio like a background music track to carry over to another scene without stopping or restarting? but in some scenes and change the music in other scenes, and Thanks!
Have you tried using
DontDestroyOnLoad (myGameObject);
where myGameObject is an extra gameObject that plays music, does control, etc.
This should make the GameObject given be kept upon loading a new scene.
Answer by W.Walter · Jan 17, 2015 at 12:51 AM
I believe this would be possible. For a start you would need to use DontDestroyOnLoad (look it up in the documentation) on your music track GameObject so that it doesn't get destroyed when the new level gets loaded (you could then destroy it yourself later). Also, you may have to use LoadLevelAsync (unfortunately its pro only) to avoid the game completely freezing while it loads the new level... not 100% sure about that though.