Play music through scene changes


I’m new to fmod and I’m impressed by the power it provides for game developing. Nevertheless, I’m trying to do something that I think is typical and hope that someone could give me a clue. I’m trying to play a theme with fmod that “survives” when a new scene is loaded in Unity.

In the first scene I have a GameObject with the FMOD_Listener and another script that creates the event instance, starts the music and sets “DontDestroyOnLoad”.

	private FMOD.Studio.EventInstance _musicEvent;
	private FMOD.Studio.ParameterInstance _exitParameter;

	void Start () 
		_musicEvent = FMOD_StudioSystem.instance.getEvent("event:/Music/Menu");
		_musicEvent.getParameter("Exit", out _exitParameter);


The music starts to play. Then, after five seconds I load a new scene and the music stops.

My GameObject survives but the music disappears.

Could anyone help me?


Well, looking at the code I found a workaround. I added the following line to my script:


Now it’s working. Is this solution correct?


Yes that is correct, if you want to have audio to continue across scene changes you need to use DontDestroyOnLoad.