# How do I reference an EventInstance in another script?

**URL:** <https://qa.fmod.com/t/how-do-i-reference-an-eventinstance-in-another-script/19141>\
**Category:** Unity\
**Created:** [August 16, 2022, 5:46pm UTC](https://qa.fmod.com/t/how-do-i-reference-an-eventinstance-in-another-script/19141 "2022-08-16T17:46:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrd777](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@mrd777](https://qa.fmod.com/u/mrd777)\
**Post date:** [August 16, 2022, 5:46pm UTC](https://qa.fmod.com/t/how-do-i-reference-an-eventinstance-in-another-script/19141/1 "2022-08-16T17:46:41Z")

</div>

How do I set a paremeter, or stop an event instance from script B, when script A has the instance of the event?

Is there a way to allow a game designer to drag and drop an event instance from a separate script into a unity inspector? I was unable to get this working.

Of course I can use GetComponent, but that means we have to code this every time and it’s not scalable.

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [August 19, 2022, 5:59am UTC](https://qa.fmod.com/t/how-do-i-reference-an-eventinstance-in-another-script/19141/2 "2022-08-19T05:59:46Z")

</div>

> [@mrd777](#):
>
> How do I set a paremeter, or stop an event instance from script B, when script A has the instance of the event?

There are many ways you could do this. The easiest I can think of would be to create a static method in Script A that stops or sets a parameter on an event instance:

```auto
public class ScriptA
{
    static EventInstance eventInstance;

    public static void StopEventInstance()
    {
        eventInstance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
    }
}

class ScriptB
{
    void Stop()
    {
        ScriptA.StopEventInstance();
    }
}

```

> [@mrd777](#):
>
> Is there a way to allow a game designer to drag and drop an event instance from a separate script into a unity inspector? I was unable to get this working.

You can drag `EventReference` path from the [Event Browser](https://fmod.com/docs/2.02/unity/event-browser.html) into an `FMODUnity.EventReference` field in the inspector, so you can look at “ **Assets\Plugins\FMOD\src\Editor\EventBrowser.cs** ” for a reference. I think implementing Drag and Drop in the Unity Editor is a little out of scope for the forums, but here is a [Unity Editor tutorial](https://docs.unity3d.com/Manual/UIE-create-drag-and-drop-ui.html) on how this works.
