0
0

Hello!

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".

[code:3jyp6242] private FMOD.Studio.EventInstance _musicEvent;
private FMOD.Studio.ParameterInstance _exitParameter;

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

}[/code:3jyp6242]

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?

Thanks!

  • You must to post comments
0
0

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

[code:21fgd87p]DontDestroyOnLoad(GameObject.Find("FMOD_StudioSystem"));[/code:21fgd87p]

Now it’s working. Is this solution correct?

Thanks!

  • You must to post comments
0
0

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

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.