In my game, I have to do a hard reset in a certain situation, and that includes deleting the AudioListener that contains the Studio Listener.
On an EXPORTED BUILD, what I find is happening is that the RuntimeManager seems to stay active and starts to complain once the new Audio listener is created:
Exception: [FMOD] Attempted access by script to RuntimeManager while application is quitting
at FMODUnity.RuntimeManager.get_Instance () [0x00000] in :0
at FMODUnity.RuntimeManager.SetListenerLocation (Int32 listenerIndex, UnityEngine.GameObject gameObject, UnityEngine.Rigidbody2D rigidBody2D) [0x00000] in :0
at FMODUnity.StudioListener.SetListenerLocation () [0x00000] in :0
at FMODUnity.StudioListener.Update () [0x00000] in :0
And in an EDITOR BUILD I run into a different issue where it tries to MuteAllEvents() on LoadScene()
Exception: [FMOD] Attempted access by script to RuntimeManager while application is quitting
FMODUnity.RuntimeManager.get_Instance () (at Assets/Plugins/FMOD/RuntimeManager.cs:53)
FMODUnity.RuntimeManager.get_HasBanksLoaded () (at Assets/Plugins/FMOD/RuntimeManager.cs:1043)
FMODUnity.RuntimeManager.MuteAllEvents (Boolean muted) (at Assets/Plugins/FMOD/RuntimeManager.cs:1013)
FMODUnity.RuntimeManager.Update () (at Assets/Plugins/FMOD/RuntimeManager.cs:373)
Which seems to be due to line 373 on the Update() function of the RuntimeManager.cs
#if UNITY_EDITOR
MuteAllEvents(UnityEditor.EditorUtility.audioMasterMute);
What is the right way to do handle this? My goal is to load a brand new scene, meaning I will lose access to the audioListener (that contains the Studio Listener) until the new scene is loaded.
My questions:
- Should I never destroy the audioListener? How can I ‘turn off’ FMOD during a hard reset of the scenes?
- When is the RuntimeManager initialized? When I add the StudioListener component?
- Does the RuntimeManager stay active once the gameObject with the StudioListener gets destroyed?