Referencing an event programmatically in 2.0.2

I’ve recently updated a Unity project from early 2019 that used FMOD from god knows what version to 2.0.2. Everything works perfectly fine, except one thing. We have a script that does this:

var emitter = container.AddComponent<StudioEventEmitter>();
emitter.Event = "event:/UI/ChangeUnit";
playerInput.changeCharacter = emitter;

The Event string on StudioEventEmitter has been obsoleted, and we should use an EventReference instead. But the event reference is mean to be assigned from the inspector, and I’m creating these objects at runtime.

It seems like all the code for getting an EventReference from a path is editor-only (ie. EventReference.Find or EventManager.EventFromString). What’s the intended workflow for assigning sounds at runtime in 2.0.2?

Try using PathToEventReference.

1 Like