I’m at my wits end here I’m afraid, really need help I’ve done some FMOD before in C++, never had any issues, great middleware. However using it in Unity has been really difficult. I just can’t figure out how to deal with scene changes: when I change scene from a script Unity freezes and then crash. This doesn’t happen every time, but it happens enough to be a criticial issue. The stack trace (bottom) seems to suggest that FMOD is the culprit, and indeed when I remove all my FMOD listeners and emitters everything works fine with no crashes.

I need the soundscape to persist between scenes, so I use [b:15bqmgf7]DontDestroyOnLoad[/b:15bqmgf7] on my listener object. However for testing I’ve put a listener in each scene, disabled by default. Another script on the same object activates it if it is the first on around:

This isn’t working though: it breaks the sound, I get null-reference and/or "the requested event, bus or vca was not found" errors. My previous version didn’t break the sound, but didn’t stop the crash either:

[code:15bqmgf7] void OnEnable()
{
// There can only be one !
foreach(SympathyFMOD_Listener other in FindObjectsOfType(typeof(SympathyFMOD_Listener)))
if(other != this)
Destroy(other.gameObject);

// This one should remain
DontDestroyOnLoad(gameObject);
}

[/code:15bqmgf7]

So basically my choice right now, and this is after months of development and due-dates being pushed back, is between no sound or a high probability of the application crashing whenever I change scenes. Please help 😮

I’m using a version of the plugin from late last-year when development started.

I had a thought just after writing this all out clearly: it’s not the listeners I need to be worried about it’s the sound system itself. I put a breakpoint to check when the pointer to the sound system was being changed and realised that the [b:254rg192]FMOD_SoundSystem::OnDisable()[/b:254rg192] resets this to 0. That means that when the emitter show up to play it’s event at the start of the next scene it finds the system uninitialised, and since the listener persists it doesn’t reinitialise anything.

The way I solved the problem was therefore to force the "FMOD_SoundSystem" game object to persist as well, so its rawPtr is not reset to NULL in between scenes. Now I have my cake and can eat it too 😀