Bug: 'EventReference' does not contain a definition for 'Find' when running a build

My game runs perfectly fine in the Unity Editor game player, but when I go to run a Addressables Content build using the Default Build Script that ships with Unity, I get the error in the title of this post.

This is the offending line in my code that triggers the error:
fmodEvent.EventReference = FMODUnity.EventReference.Find(fmodEventPath);

If I comment this line out, I’m able to build my Addressable Assets. Why is this happening?

A quick update on this one - the error also occurs when I try to run a build and it happens with both Mono + IL2CPP Scripting Backends.

FMOD version: 2.02.03
OS: Windows 10
Unity version: 2021.1.20f1
Build Target: Windows x86_64

Ah, I think I see the issue - the FMODUnity.EventReference.Find method is only available in the UnityEditor context.

My use case is dynamically creating StudioEventEmitter components at runtime and I need to of course dynamically set the EventReference property from a path string.

It used to be as simple as this:
fmodEvent.Event = fmodEventPath;

With the latest library, how can I lookup a studio event at runtime from its path? (e.g “event:/game/music/track1” ?)

Answered my own question - this is how you do it:
fmodEvent.EventReference = FMODUnity.RuntimeManager.PathToEventReference(fmodEventPath);

1 Like

Awesome work, this issue was messing with exporting a simple build. Switched to fmodEvent.EventReference = FMODUnity.RuntimeManager.PathToEventReference(fmodEventPath); and was able to build successfully. Thank you!