Working with scene load

Hello!

First of all, I’m using Unity 6000.2.13f1 and FMOD 2.02.31 and integration 2.02.32.

A quick question: what would be the best strategy to “persist” a oneshot sound across scenes?

In my game I can open doors and go up/down stairs to go to other scenes. Both these doors and stairs objects have a FMODStudioEventEmitter component attached to them, so when the player interacts with it, I play the desired sound event. However, I’d like to keep playing the sound across scenes, so when the new scene loads, the event is playing until it finishes.

Both events are Action 2D, however:

  • The door sound event have an open and a close sound that play in a consecutive way.

  • The stair sound event is a multi instrument, where I’m randomizing n sounds and playing it m times.

What I noticed is that the stair event sometimes stutter in Unity, like it play 3 times and then the last one with a bit of a delay (and in FMOD, when I hit the play button, sometimes it plays faster and sometimes a little bit slower :thinking:).

Also, I’m always getting the log warning [FMOD] SoundSourceInstrumentInstance::startChannelIfReady : Loading delay exceeded, sound may play at incorrect time when dealing with both events.

Any ideas what I might be doing wrong? I read somewhere that it might be related to the fact that the sounds aren’t fully loaded and I’m trying to play it. I followed some instructions (such as marking ‘Preload Sample Data’ or ‘Load Banks’ set to ‘All’ in FMOD Settings inside Unity) but I’m still facing the same problem.

Hi,

Thank you for sharing the information!

For one shots that need to continue playing across scene loads, the safest approach is to create the EventInstance manually (instead of relying on a StudioEventEmitter on a scene object) and let it live in a DontDestroyOnLoad manager. Once started, the instance will keep playing until it finishes, even if Unity loads a new scene.

This usually means the sample data wasn’t fully loaded when the instruments triggered. Could you please double check that the assets aren’t set to Stream, and that Preload Sample Data is enabled on the events?

Some related suggestions are also mentioned in this thread , does any of those help in your case?

Thanks for the reply!

I tried doing that, but I’m still facing the same problem. I used FMODStudioEventEmitter just to hold the EventReference, but I created an event instance inside a test script, set it to DontDestroyOnLoad and started > released > cleared the handle. No sucess, though.

My settings are exactly like that!

Is there anything else I can try? I’m not really sure, but the footsteps sounds I’m trying to play are like 0.2s each. Maybe there is a connection? :thinking:

Thanks for sharing the extra info!

Would it be possible to share a minimal repro project so I can take a closer look to better understand the setup? You can upload it to your profiler.

Apparently I just fixed it by turning on Loading mode to Stream in my Assets Browser, but I’m not sure why.

It seems I didn’t even need to do the DontDestroyOnLoad part and create an event instance. I simply created a FMODStudioEventEmitter variable and called the method Play().

To be sure, I debugged the FMODStudioEventEmitter and apparently I’m not getting any memory leaks since it is releasing and cleaning the handle.

Should I pay attention to anything elseby following this approach?

Thank you.

Thanks for the update and sharing your solution here!

If switching the asset Loading Mode to Stream resolved your issue, that makes sense.

Streaming assets are read from disk as needed, so FMOD doesn’t need the full sample data to be ready upfront. That said, streaming is generally best suited for longer assets (music/ambience) and cases where only a few instances play at once. For lots of short one-shots (e.g. ~0.2s footsteps), streaming can introduce disk I/O dependency, so it’s worth keeping an eye on it when profiling or testing on target platforms. There’s a useful discussing on when to use stream assets here : When to stream assets and when not to - #2 by joseph

Also, if you still run into the Loading delay exceeded warning in other cases, this thread may also help: Loading delay exceeded warning when using Programmer Instrument and Audio Table - #2 by joseph