# Specify event path in code

**URL:** https://qa.fmod.com/t/specify-event-path-in-code/19250
**Category:** Unity
**Created:** [September 8, 2022, 10:19am UTC](https://qa.fmod.com/t/specify-event-path-in-code/19250 "2022-09-08T10:19:21Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![g.hadji](https://avatars.discourse-cdn.com/v4/letter/g/b19c9b/32.png) [@g.hadji](https://qa.fmod.com/u/g.hadji)
#### Post date: [September 8, 2022, 10:19am UTC](https://qa.fmod.com/t/specify-event-path-in-code/19250/1 "2022-09-08T10:19:22Z")

</div>

Hi,

In the latest version of fmod for unity it was possible to **specify the path of an event directly in code** :

`[EventRef] private string myEvent = "path of my event";`

With the latest version of the plugin, I had to replace all my **[EventRef]** by **EventReference**. But now I don’t know how to specify the path of my event and the only way for me to connect my event to my event Reference is to do it via the **Unity Editor**. If I try to this :

`private EventReference myEvent = "path of my event";`

I get the error :

> Cannot implicitly convert type ‘string’ to ‘FMODUnity.EventReference’

This can be very inconvenient sometimes. For exemple if I want to specify my event from the UI, it will automatically modify the scene containing the game object the script is attached to in source control, which can be a problem if another develloper is working on the scene at the same time.

So what do I have to give to EventReference so it understand the event I want to attached to it ?

**Is there still a way to get my event to connect to the reference without being dependant of the editor ?**

Thanks for your response.

---

<div class="post-metadata">

### Author: ![ManWhoCanFly](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/manwhocanfly/32/962_2.png) [@ManWhoCanFly](https://qa.fmod.com/u/ManWhoCanFly)
#### Post date: [September 8, 2022, 12:48pm UTC](https://qa.fmod.com/t/specify-event-path-in-code/19250/2 "2022-09-08T12:48:09Z")

</div>

This is the proper way to assign default value to event paths

> #if UNITY\_EDITOR  
> void Reset()  
> {  
> eventReference = FMODUnity.EventReference.Find(“event:/music/music”);  
> }  
> #endif

From: [https://fmod.com/docs/2.02/unity/api-common.html#eventreference](https://fmod.com/docs/2.02/unity/api-common.html#eventreference)
