- Home /
This question was
closed Aug 02, 2013 at 02:57 PM by
DaveA for the following reason:
Duplicate Question: search
Question by
chrishall · Aug 02, 2013 at 02:36 PM ·
audiotriggerbackground music
How do I keep background music playing when I enter another level
Hi I am creating a simple plat forming game. And I would like to have the background music keep going and not restart in the new level. Sort of like a continuous loop. Is there anyway I could do this?
Comment
Asked and answered many times; http://lmgtfy.com/?q=How+do+I+keep+background+music+playing+when+I+enter+another+level+unity
You want to attach the audio to a game object that doesn't get destroyed on load so it stays throughout load levels.
void Awake() {
DontDestroyOnLoad(transform.gameObject);
}
See: http://docs.unity3d.com/Documentation/ScriptReference/Object.DontDestroyOnLoad.html
Answer by boni · Aug 02, 2013 at 02:55 PM
You probably need to keep the objects that play the music and listen to it intact.
See this Answer