# Referencing an event programmatically in 2.0.2

**URL:** https://qa.fmod.com/t/referencing-an-event-programmatically-in-2-0-2/18076
**Category:** Unity
**Created:** [December 9, 2021, 10:43am UTC](https://qa.fmod.com/t/referencing-an-event-programmatically-in-2-0-2/18076 "2021-12-09T10:43:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Baste](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@Baste](https://qa.fmod.com/u/Baste)
#### Post date: [December 9, 2021, 10:43am UTC](https://qa.fmod.com/t/referencing-an-event-programmatically-in-2-0-2/18076/1 "2021-12-09T10:43:56Z")

</div>

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:

```auto
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?

---

<div class="post-metadata">

### Author: ![alexzzen](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/alexzzen/32/6825_2.png) [@alexzzen](https://qa.fmod.com/u/alexzzen)
#### Post date: [December 9, 2021, 2:24pm UTC](https://qa.fmod.com/t/referencing-an-event-programmatically-in-2-0-2/18076/2 "2021-12-09T14:24:28Z")

</div>

Try using [PathToEventReference](https://www.fmod.com/resources/documentation-unity?version=2.02&page=api-runtimemanager.html#pathtoeventreference).
