# How can I preview Programmer Sounds in Unity Editor (accessing the AudioTable)?

**URL:** <https://qa.fmod.com/t/how-can-i-preview-programmer-sounds-in-unity-editor-accessing-the-audiotable/16516>\
**Category:** Unity\
**Created:** [December 3, 2020, 10:27pm UTC](https://qa.fmod.com/t/how-can-i-preview-programmer-sounds-in-unity-editor-accessing-the-audiotable/16516 "2020-12-03T22:27:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![facaelectrica](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/facaelectrica/32/105_2.png) [@facaelectrica](https://qa.fmod.com/u/facaelectrica)\
**Post date:** [December 3, 2020, 10:27pm UTC](https://qa.fmod.com/t/how-can-i-preview-programmer-sounds-in-unity-editor-accessing-the-audiotable/16516/1 "2020-12-03T22:27:58Z")

</div>

I’ve used the _EventBrowser.cs_ as well as _EditorUtils.cs_ to create my own Audio preview editor in Unity, and I’m able to play event sounds just like the Event Browser.

The issue I’m running into is that I can’t figure out how to preview/access _ **Programmer sounds** _.  
I can’t figure out how to access an AudioTable and assign it to an EditorEventRef through the Editor. Kind of like we would do in-game:

```
eventInstance.setUserData(GCHandle.ToIntPtr(stringHandle));
eventInstance.setCallback(dialogueCallback);

```

I can’t seem to find an example to go from in the FMOD Editor menu options, making me wonder if its possible or not.

UPDATE:  
To be more precise, I’m trying to understand how to call the equivalent methods between _ **EventInstance** _ methods and _ **EditorEventRef** _ (Or at least I assume that is the right way to go at this).

For example, if I want to change a parameter in a Editor instance rather than doing:

`eventInstance.setParameterByName("parameterName", parameterValue);`

I do:

```
foreach (EditorParamRef selectedParamRef in eventRef.Parameters) {
     if (selectedParamRef.Name == "parameterName") selectedParamRef.Default = parameterValue;
}

```

My question is, how can I do this for the following methods (used for Programmer sounds)?

```
eventInstance.setUserData(GCHandle.ToIntPtr(stringHandle));
eventInstance.setCallback(dialogueCallback);
```

---

<div class="post-metadata">

**Author:** ![facaelectrica](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/facaelectrica/32/105_2.png) [@facaelectrica](https://qa.fmod.com/u/facaelectrica)\
**Post date:** [December 8, 2020, 3:20pm UTC](https://qa.fmod.com/t/how-can-i-preview-programmer-sounds-in-unity-editor-accessing-the-audiotable/16516/2 "2020-12-08T15:20:28Z")

</div>

Anyone? About to give up on this due to project deadlines.

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [December 10, 2020, 4:31am UTC](https://qa.fmod.com/t/how-can-i-preview-programmer-sounds-in-unity-editor-accessing-the-audiotable/16516/3 "2020-12-10T04:31:26Z")

</div>

`setUserData` and `setCallback` need to be called from the eventInstance that is created, are you handling that or is that being handled by the integration?

---

<div class="post-metadata">

**Author:** ![facaelectrica](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/facaelectrica/32/105_2.png) [@facaelectrica](https://qa.fmod.com/u/facaelectrica)\
**Post date:** [December 10, 2020, 3:29pm UTC](https://qa.fmod.com/t/how-can-i-preview-programmer-sounds-in-unity-editor-accessing-the-audiotable/16516/4 "2020-12-10T15:29:19Z")

</div>

Thank you for replying Cameron That was it! I realized where the eventInstance is created and running it there works! Yay!

The only question I have is about the creation of the _dialogueCallback_.  
For the game, I follow your tutorial and I set it on Start() :

```
	public void Start(){
        // Explicitly create the delegate object and assign it to a member so it doesn't get freed
        // by the garbage collected while it's being used
       ToolsAudio.dialogueCallback = new FMOD.Studio.EVENT_CALLBACK(ToolsAudio.DialogueEventCallback);
    }

```

But for the editor, should I do it when I **CreateSystem()** or the moment I call the _eventInstance_? Also once it’s done, how do I remove the callback? Or that is not necessary?

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [December 11, 2020, 4:05am UTC](https://qa.fmod.com/t/how-can-i-preview-programmer-sounds-in-unity-editor-accessing-the-audiotable/16516/5 "2020-12-11T04:05:59Z")

</div>

You only need to create the callback before it gets used, so in this case just after the event instance is created should be fine. Also you shouldn’t need to worry about removing the callback, once the instance gets cleaned up it will remove the callback internally.
