---
tags:
    - "Execute"
    - "Play"
    - "Run"
    - "Call"
    - "Action"
    - "Trigger"
    - "Instruction"
---

# Run Event

[Control](index.md) / **Run Event**

## Description

Forces an Event to run

## Parameters

| Name | Description |
| :--- | :---------- |
| Event | The scene Event component to execute |
| Source | The Source object referenced in the call |
| Target | The Target object referenced in the call |
| Await | Whether to await the event to finish or not |

## Code

```cs
using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Title("Run Event")]
    [Image(typeof(IconEvent), ColorTheme.Type.Blue)]

    [Description("Forces an Event to run")]
    [Category("Control/Run Event")]

    [Parameter("Event", "The scene Event component to execute")]
    [Parameter("Source", "The Source object referenced in the call")]
    [Parameter("Target", "The Target object referenced in the call")]
    [Parameter("Await", "Whether to await the event to finish or not")]

    [Keywords("Execute", "Play", "Run", "Call")]
    [Keywords("Action", "Trigger", "Instruction")]

    [Serializable]
    public class InstructionCoreRunEvent : Instruction
    {
        [SerializeField]
        private GetGameObject m_Event = new GetGameObject(new TypeGameObjectComponentEvent());

        [SerializeField]
        private GetGameObject m_Source = new GetGameObject(new TypeGameObjectSource());

        [SerializeField]
        private GetGameObject m_Target = new GetGameObject(new TypeGameObjectTarget());

        [SerializeField] private bool m_Await = true;

        protected override string GetTitle(GameObject source)
        {
            string await = this.m_Await ? " and wait" : string.Empty;
            return $"Run {this.m_Event}{await}";
        }

        protected override async Awaitable Run(Args args)
        {
            Event instance = this.m_Event.Get<Event>(args);
            if (instance == null) return;

            GameObject source = this.m_Source.Get(args);
            GameObject target = this.m_Target.Get(args);

            using Args eventArgs = Args.Get(source, target);
            Awaitable awaitable = instance.Schedule(eventArgs);

            if (this.m_Await)
            {
                await awaitable;
            }
            else
            {
                awaitable.Fire();
            }
        }
    }
}
```

