Hello,
As the title says, I’ve got a project in Unity (2021.3.24f1) and connected it to an FMOD project (FMOD Studio V2.02.09, Build#128289)
Triggering sounds, loading banks and all that works fine in Editor Playmode.
But when I exit play mode and go back to the editor, all sounds that were playing when I quit just keep playing.
Loops will continue indefinitely, while One-Shots will play until the end of the event.
As far as I understand, exiting playmode should result in all Objects within the active Scene being destroyed. All my event emitter components are setup to Stop playback OnDestroy, but this does not work as intended.
If an object with an emitter attached to it is destroyed while the scene runs, the sounds stop immediately.
Did anyone run into this issue before and found a solution or is something fundamentally wrong with my FMOD integration?
Unfortunately, using a simple looping event played by an event emitter, I haven’t been able to reproduce the issue you’re describing.
Is there anything else that you’re doing to play your events besides using event emitters? Have you made any modifications to the integration code in anyway? Can I get you tick Enable API Error Logging and set your Logging Level to “Log” in your FMOD for Unity settings, and post the output of your game’s log here?
Well I am starting the events from a script, just telling the event emitter to start playback.
But as all my sounds behave this way, even the oneshots it does not seem to matter how I trigger them. Even if I put them on “play on objectstart”, they dont stop when I quit the scene.
Only way to stop the playback is to hit Unitys “Pause” button at the top. That pauses the sounds correctly, even after I’ve quit playmode. They just never really stop.
I have not made any changes to the integration code.
I will try to post the log files in the next couple days!
Solution Found (for us at least)! - We are in Unity 2021.3.38f1 & FMOD 2.02.26
What Caused the Issue - Cinemachine Virtual Cameras have a “Save During Play” setting. When checked, it creates a global EditorPrefs variable that is not deleted when you delete the virtual camera. If your scene has ANY cinemachine component in it (we were using a CinemachinePath for an audio source along a river) it can cause an Argument Exception Error when the scene is unloaded due to a subscription to EditorApplication.playModeStateChange. FMOD also uses EditorApplication.playModeStateChange to stop sounds, so an error during this could stop this from firing. Different computers subscribe to things in different orders, hence why one computer could have no issue while another could have this problem, just depends on if the FMOD events would happen before or after the error.
Fix - Add a virtual camera to any object, set “Save During Play” to OFF, delete camera. This should stop the error from happening which in turn stops FMOD sounds from continuing to play!