# Assigning Event Paths at Runtime?

**URL:** <https://qa.fmod.com/t/assigning-event-paths-at-runtime/22970>\
**Category:** Unity\
**Created:** [May 23, 2025, 10:14pm UTC](https://qa.fmod.com/t/assigning-event-paths-at-runtime/22970 "2025-05-23T22:14:14Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Why485](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/why485/32/6839_2.png) [@Why485](https://qa.fmod.com/u/Why485)\
**Post date:** [May 23, 2025, 10:14pm UTC](https://qa.fmod.com/t/assigning-event-paths-at-runtime/22970/1 "2025-05-23T22:14:14Z")

</div>

I’m going crazy because I _have_ to be misunderstanding something, and I have a hard time believing that FMOD lost a feature so critical.

How can I create/assign an EventReference at runtime?

Something like:

```cs
string eventPathLoadedFromDataFile = loadedData.jetAudioPath;
jetEmitter.EventReference = new EventReference(eventPathLoadedFromDataFile);

```

The above code obviously doesn’t work, but that’s the gist of what I’m trying to do. There doesn’t seem to be any way to achieve that kind of behavior with the new way `EventReference` works compared to `EventRef` of older FMOD. This is a _completely_ breaking change for my game, because my game creates all its vehicles and aircraft at runtime using JSON defined paths. For example the vehicle definition has this property:

```json
"EngineSound": "event:/Vehicles/TankEngine",

```

Is this impossible now?

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [May 26, 2025, 3:58am UTC](https://qa.fmod.com/t/assigning-event-paths-at-runtime/22970/2 "2025-05-26T03:58:48Z")

</div>

Hi,

Sorry, I don’t understand the issue.

Could I grab some more info:

- What is being created at runtime?
- What version of FMOD were you able to do this in previously?
- Do you have a working code snippet I could see?
- Is there any docs you can point to with this functionality?

Any more info would be greatly appriciated.

---

<div class="post-metadata">

**Author:** ![Why485](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/why485/32/6839_2.png) [@Why485](https://qa.fmod.com/u/Why485)\
**Post date:** [May 28, 2025, 1:22pm UTC](https://qa.fmod.com/t/assigning-event-paths-at-runtime/22970/3 "2025-05-28T13:22:08Z")

</div>

> What is being created at runtime?

`StudioEventEmitters` are part of various Unity prefabs, however they do not have an event associated with them until runtime, where data loaded from the disk then populates them with an event reference string.

> What version of FMOD were you able to do this in previously?

2.00.08

> Do you have a working code snippet I could see?

There is no working code snippet anymore, but this is an example of code that used to work.

```cs
if (Data.EngineSound.Length > 0f)
{
    EngineSoundEmitter.Event = Data.EngineSound;
    EngineSoundEmitter.Play();
}

```

The `Data.EngineSound` is just a string that is the name of an event. E.g. `event:/Vehicles/TankEngine`. The value of this string is read in from various files for various different vehicles at runtime based on JSON data files.

`.Event` is no longer usable, and I can’t find a replacement that lets me do the same thing. It’s suggested to use `EventReference` but there doesn’t seem to be a way to create these at runtime. `FMODUnity.EventReference.Find()` _should_ work, but this code **does not work in a build** since it is surrounded by `#if` guards. I’ve been trying to work around this by moving code out of the `#if UNITY_EDITOR` blocks, but it was at this point where I was starting to get enough into the weeds with changing FMOD code that I had to stop and ask if I was missing something obvious.

> Is there any docs you can point to with this functionality?

[https://www.fmod.com/docs/2.00/unity/api-studioeventemitter.html#studioeventemitter\_event](https://www.fmod.com/docs/2.00/unity/api-studioeventemitter.html#studioeventemitter_event)

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [May 29, 2025, 4:37am UTC](https://qa.fmod.com/t/assigning-event-paths-at-runtime/22970/4 "2025-05-29T04:37:10Z")

</div>

Thank you for the additional information.

Would [Unity Integration | Scripting API Reference - RuntimeManager::PathToEventReference()](https://fmod.com/docs/2.02/unity/api-runtimemanager.html#pathtoeventreference) work? It can be used like so:

```C
emitter = GetComponent<FMODUnity.StudioEventEmitter>();
emitter.EventReference = FMODUnity.RuntimeManager.PathToEventReference("event:/Music/Level 01");
emitter.Play();

```

This would still allow you to use the paths to create and play events using an emitter.

Hope this helps

---

<div class="post-metadata">

**Author:** ![Why485](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/why485/32/6839_2.png) [@Why485](https://qa.fmod.com/u/Why485)\
**Post date:** [May 30, 2025, 4:37am UTC](https://qa.fmod.com/t/assigning-event-paths-at-runtime/22970/5 "2025-05-30T04:37:51Z")

</div>

The good news is that solves the problem of assigning events at runtime. Thank you.

However that brings me back to my original problem _before_ this one. I have searched for it in all results I’ve come up with suggest preloading the banks, but that hasn’t worked neither when I do it through settings or manually through code.

For future search indexing, the specific log message is:  
`Loading delay exceeded. Instrument {7eb1e17c-fab3-440d-8bcf-25bc5ab701fd} started 76.87ms later than expected, sound may play at incorrect time. SCHEDULE_DELAY: 170.67ms.`

The log gets bombarded with these messages, and then the sound playing gets completely out of sync with the action. This **did not happen** until I moved Unity version to 2023.2 from 2020.3.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/e/e54cedc761136ca28fe9871cf114c88ebdcf51fc.jpeg)

This problem has been stumping me for the last week, and I’m very close to just reverting the engine to 2020 and sucking it up, because FMOD is the sole reason I can’t go through with the engine update and I can’t even figure out where to begin debugging this.

At first I thought it was a mismatched FMOD/Unity combination, but even on FMOD 2.00.08 (the FMOD the game originally used on Unity 2020.3), this delay issue was happening. So I tried updating FMOD to 2.03.07 thinking that might fix it and that update process was painful but seems to be done. However it has done nothing to fix this issues with out of sync audio, so there’s _something_ that changed in Unity 2023 that is completely destroying the audio in my game.

The only interesting information I can report is that when there is a single aircraft flying around, the audio is (usually) okay, but something about multiple causes the audio engine to become completely non-responsive.

I am not using Programmer Instruments.

If this was just a one-time thing per game session I’d be more forgiving, but this issues pops up regularly during gameplay with seemingly every new sound causing the audio to become completely unsynched.

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [May 30, 2025, 5:10am UTC](https://qa.fmod.com/t/assigning-event-paths-at-runtime/22970/6 "2025-05-30T05:10:41Z")

</div>

Good to hear we solved that issue.

Thank you for all the information.

To help the delayed sound problem, could you please enable the `Load Bank Sample Data` option in the integration settings:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/7/745fd60552e4baecca61c09f2392f9c7179ebbc1.png)  
This reduces latency at the cost of using more memory: [Unity Integration | Settings - Load Bank Sample Data](https://fmod.com/docs/2.02/unity/settings.html#load-bank-sample-data)

Hope this helps

---

<div class="post-metadata">

**Author:** ![Why485](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/why485/32/6839_2.png) [@Why485](https://qa.fmod.com/u/Why485)\
**Post date:** [May 30, 2025, 5:12am UTC](https://qa.fmod.com/t/assigning-event-paths-at-runtime/22970/7 "2025-05-30T05:12:23Z")

</div>

Yes that was already checked.

However, after banging my head on this problem for almost 2 weeks, I noticed that for some reason a bunch of audio assets (notably the problematic ones) in my FMOD Studio project got marked as `STREAM` when they were never meant to. I’m not sure when that happened or how, but setting them back to not streaming anymore (the `STREAM` button goes gray, plus they lose the `STREAM` tag) _seems_ to have resolved the issue?

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/a/a3d9cda4ae552324950574004268d0826b0b98dd.png)

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [June 1, 2025, 10:16pm UTC](https://qa.fmod.com/t/assigning-event-paths-at-runtime/22970/8 "2025-06-01T22:16:10Z")

</div>

Thank you for sharing the solution.

---

<div class="post-metadata">

**Author:** ![Why485](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/why485/32/6839_2.png) [@Why485](https://qa.fmod.com/u/Why485)\
**Post date:** [June 3, 2025, 7:24pm UTC](https://qa.fmod.com/t/assigning-event-paths-at-runtime/22970/9 "2025-06-03T19:24:16Z")

</div>

When I try to use `EventReference.Find()` in a build, it throws an error.

```auto
EventReference.Find called before EventManager was initialized

```

How can I initilize the EventManager manually since that seems to not be happening in a build?

Looking at the source, this seems to be a feature, not a bug, since the `EventManager` is only available in the Editor.

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [June 4, 2025, 12:03am UTC](https://qa.fmod.com/t/assigning-event-paths-at-runtime/22970/10 "2025-06-04T00:03:58Z")

</div>

Correct. What functionality are you looking for in build?

---

<div class="post-metadata">

**Author:** ![Why485](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/why485/32/6839_2.png) [@Why485](https://qa.fmod.com/u/Why485)\
**Post date:** [June 4, 2025, 12:52am UTC](https://qa.fmod.com/t/assigning-event-paths-at-runtime/22970/11 "2025-06-04T00:52:31Z")

</div>

To be able to assign event reference at runtime based on the string path to an event as I described in the OP and my second post.

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [June 4, 2025, 3:30am UTC](https://qa.fmod.com/t/assigning-event-paths-at-runtime/22970/12 "2025-06-04T03:30:39Z")

</div>

I see, was this solved by [Assigning Event Paths at Runtime? - #4 by Connor\_FMOD](https://qa.fmod.com/t/assigning-event-paths-at-runtime/22970/4)?

---

<div class="post-metadata">

**Author:** ![Why485](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/why485/32/6839_2.png) [@Why485](https://qa.fmod.com/u/Why485)\
**Post date:** [June 4, 2025, 5:15pm UTC](https://qa.fmod.com/t/assigning-event-paths-at-runtime/22970/13 "2025-06-04T17:15:05Z")

</div>

You’re, right. I’m sorry, I got confused with the function names and mixed up the `EventReference.Find()` with `RuntimeManager.PathToEventReference()`.

The good news is that it loads up and sounds mostly kind of work now. However I still get unplayable stuttering when certain sounds are triggered, and sometimes sounds don’t play at all.

It works perfectly in the Editor, with no errors or warnings thrown. However in the build e.g. when this bullet flyby sound effect is meant to played the game’s framerate crawls to a standstill. This is only the easiest and most reproducible Build only bug, but I assume it’s indicative of what’s happening elsewhere.

[![](https://img.youtube.com/vi/JBq8qfVm94g/hqdefault.jpg "Arena 2025 06 04 13 07 26") ](https://www.youtube.com/watch?v=JBq8qfVm94g)

Attached is the log, which is full of FMOD related warnings and errors.  
[Player.log](https://qa.fmod.com/uploads/short-url/kli2fmvyLMAsX2rUu6qNdlAoccU.log) (268.5 KB)

What is going on here, and why is this only happening in the build? It works fine in the Editor (albeit audio levels are strange compared to what they should be, but that at least seems fixable and is probably an artifact of moving from 2.00 to 2.03). It’s only in the Build where it becomes unplayable with missing seemingly missing SFX and harsh stutters.

---

<div class="post-metadata">

**Author:** ![Why485](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/why485/32/6839_2.png) [@Why485](https://qa.fmod.com/u/Why485)\
**Post date:** [June 4, 2025, 5:41pm UTC](https://qa.fmod.com/t/assigning-event-paths-at-runtime/22970/14 "2025-06-04T17:41:35Z")

</div>

I’ve been able to roll back to 2.00.08, but on Unity 2023. With the streaming audio fix mentioned earlier in the thread, everything _seems_ to be working again.

I’m staying away from 2.03 and will continue using 2.00 for the remainder of this project and praying nothing else goes wrong.

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [June 4, 2025, 9:31pm UTC](https://qa.fmod.com/t/assigning-event-paths-at-runtime/22970/15 "2025-06-04T21:31:28Z")

</div>

Thank you for the information and the video.

I understand, if you decide to return to 2.03 there are some more options we have for investigating the issue.
