Updating from 2.02 to 2.03 issues

Unity 2022.3.48.f1, FMOD 2.02.17 → 2.03.05

I was trying to update our project to the latest FMOD because there are some new features/bugfixes that I’d really love to take advantage of. I followed the update process (in Unity and Studio) and it seemed to work fine, including the event reference updater.

On entering play mode the first time everything worked perfectly as before. However, after stopping, and then entering play mode again I get no sound and hundreds of null event references in the console. The assynccommandbuffer also continues to get bigger and bigger. As I leave play mode again I get a tiny burst of all the sounds that should have been playing.

Is there anything I may have missed while updating that could cause this?

Just to confirm, have you rebuild your banks using Studio 2.03.05 and made sure to import/refresh them in Unity? Attempting to open 2.02 banks with 2.03 may explain the issues you’re running into.

Otherwise, in the Initialization section of FMOD for Unity’s settings, could I get you to set the logging level to “Log” and enable API error logging, and post a log from play mode where the issues are occurring so I can take a look? If you’re receiving any FMOD logs in editor, posting your editor log would also be helpful.

Hi Leah thanks for your reply. Yes banks were rebuilt.

On retrieving the logs I noticed I’d described the problem incorrectly - It’s not null references but missing references:

MissingReferenceException: The object of type ‘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.
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)

Have attached the log, but have collapsed it so you don’t see hundreds of the same error message.
ConsoleLog.txt (1.1 MB)

Just to clarify, I don’t get these error messages on the first time entering play mode, only on successive times

Thanks for the additional information and log.

I haven’t been able to reproduce the issue on my end, but I suspect the upgrade to 2.03 has changed how your own audio classes, such as AudioDestructibleObject, are interacting with the FMOD Studio system and handling any event instances or Event Emitter components.

The MissingReferenceException would likely be caused by StudioEventEmitters being registered with the FMOD Unity integration but being destroyed without being unregistered. The command buffer issue would either be caused by something unintentionally causing a growing amount of commands, or Studio System update not being called, which would cause the command buffer to not be submitted to FMOD.

Could I get you to post the code for AudioDestructibleObject so I can take a closer look?

Here’s the code, now I’m looking at it it does look a bit (s)crappy!

I could understand this code causing problems on those specific objects, but why do you think the inbuilt StudioEventEmitters aren’t getting unregistered when leaving play mode?

public class AudioDestructibleObject : MonoBehaviour
{
    [SerializeField] private EventReference _breakEvent;
    [SerializeField] private EventReference _bounceEvent;
    [SerializeField] private string _velocityParam = "ImpactVelocity";
    [SerializeField] [Range(0, 20)] private float _maxVelocity;

    private EventInstance _instance;
    private PARAMETER_ID _velocityParameterID;

    public void OnObjectBreak()
    {
        RuntimeManager.PlayOneShotAttached(_breakEvent, gameObject);
    }

    private void Start()
    {
        _instance = RuntimeManager.CreateInstance(_bounceEvent);
        RuntimeManager.AttachInstanceToGameObject(_instance, transform);
        
        EventDescription bounceEventDescription;
        _instance.getDescription(out bounceEventDescription);
        
        PARAMETER_DESCRIPTION velocityParameterDescription;
        bounceEventDescription.getParameterDescriptionByName(_velocityParam, out velocityParameterDescription);

        _velocityParameterID = velocityParameterDescription.id;
    }

    private void OnCollisionEnter(Collision other)
    {
        float relativeImpactVelocity = other.relativeVelocity.magnitude;
        // Debug.Log("Impact Velocity: " + relativeImpactVelocity);

        _instance.set3DAttributes(transform.position.To3DAttributes());
        _instance.start();
        _instance.setParameterByID(_velocityParameterID, ScaleVelocity(relativeImpactVelocity));
    }

    private float ScaleVelocity(float velocity)
    {
        return Mathf.Clamp01(velocity / _maxVelocity);
    }

    private void OnDestroy()
    {
        _instance.release();
    }
    
}

Apologies for the delayed response.

After some testing on my end, AudioDestructibleObject seems to be fine, so it’s probably something else in the audio code that’s causing the issue, likely something that’s explicitly destroying StudioEventEmitter components in some way. If possible, could I get you to upload a stripped down version of your project where you can still reproduce the issue to your FMOD User profile?