Missing Reference Exception (StudioEventEmitter)

Hello,

We’re running into a pretty bad error when exiting play mode while an event is playing.

MissingReferenceException: The object of type 'FMODUnity.StudioEventEmitter' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Object+MarshalledUnityObject.TryThrowEditorNullExceptionObject (UnityEngine.Object unityObj, System.String parameterName) (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:869)
UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj) (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/BindingsHelpers.cs:61)
UnityEngine.Component.get_transform () (at <c6fcfbd931e348ecb5b0d76a4ac091c6>:0)
FMODUnity.StudioEventEmitter.UpdatePlayingStatus (System.Boolean force) (at Assets/Plugins/FMOD/src/StudioEventEmitter.cs:106)
FMODUnity.StudioEventEmitter.UpdateActiveEmitters () (at Assets/Plugins/FMOD/src/StudioEventEmitter.cs:86)
FMODUnity.RuntimeManager.Update () (at Assets/Plugins/FMOD/src/RuntimeManager.cs:464)

We have this event which sets a radiation level and plays a sound, there’s 2 sounds which aren’t looping and the critical sound has 2 levels of nested events which has a looping sound in the bottom event, there’s only two trigger conditions on the parent event which stops the nested when the event is stopped and plays a reset sound. Another thing to note is on any radiation value under 80 we call stop on the emitter straight away after playing so it plays out, then only call stop on a value over 80 when the detector is reset. if we don’t call stop then the event loops indefinitely.

On exiting play mode and re-entering we get the error and pretty much have to exit the editor to reset it. We prevented this by calling stop explicitely in our script’s OnDestroy() which fixes the issue it seems but I guess the question is shouldn’t all StudioEventEmitters by default be releasing in OnDestroy()?

Line 163 of StudioEventEmitter in OnDestroy()

if (eventDescription.isValid() && isOneshot)
{
    instance.release();
    instance.clearHandle();
}

Does the emitter only release instances if they’re marked as OneShot in OnDestroy() and is this the thing that could be causing issues? I can’t trace where we’re releasing this event instance unless stopping it ourselves.

Thanks for your time

Hi,

This likely isn’t an issue with the event instance itself, but instead with the emitter component. A couple of questions:

  • What version of FMOD for Unity are you using? Have you recently updated from 2.02 to 2.03?
  • What version of Unity are you using?
  • Does this occur in specific scenes, or in all scenes when exiting play mode, even an empty scene with just a Listener and Event Emitter?
  • Are there any of your own scripts instantiating/destroying or otherwise managing StudioEventEmitters at run time? If so, could I get you to share the relevant parts of the scripts?
  • You mention you get the error when re-entering play mode - can I get you to elaborate on exactly what happens on re-entering play mode? Do you just recieve the error, or is FMOD playback also affected?