# SimpleScript.OnScriptEventOptionsAttribute

Kind: Class · Namespace: Sansar.Simulation · Assembly: Sansar.Simulation.dll · Script API 47.10.0

<div class="api-meta">
<span class="api-kind api-kind-class" data-pagefind-filter="kind:Class">Class</span>
<span data-pagefind-filter="namespace:Sansar.Simulation">Namespace <a href="/scripting/api/sansar.simulation"><code>Sansar.Simulation</code></a></span>
<span>Inherits <a href="/scripting/api/sansar.simulation/simplescript.simplescriptoptionsattribute">SimpleScript.SimpleScriptOptionsAttribute</a></span>
</div>

<span id="T:Sansar.Simulation.SimpleScript.OnScriptEventOptionsAttribute"></span>

Set options for OnScriptEvent events.

```csharp
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false)]
[System.Obsolete("SimpleScript is deprecated and will not receive new features. Please use SceneObjectScript or ObjectScript.", false)]
protected class SimpleScript.OnScriptEventOptionsAttribute : SimpleScript.SimpleScriptOptionsAttribute
```

## Remarks

If EventName is not set then OnScriptEvent will receive events with the name of the script class.

## Example

```csharp
// Send events to this handler from other simple scripts with: PostScriptEvent("AddPosition", myVector);
[OnScriptEventOptions(EventName="AddPosition")]
protected override void OnScriptEvent(object eventData)
{
    Vector newPos = eventData as Vector;
    if (newPos != null) AllPositions.Add(newPos);
}
```

## Members at a glance

| Kind | Members |
|---|---|
| **Constructors** | [OnScriptEventOptionsAttribute](#onscripteventoptionsattribute) |
| **Properties** | [Message](#message) |

## Constructors

### OnScriptEventOptionsAttribute

<div class="api-card">
<span id="M:Sansar.Simulation.SimpleScript.OnScriptEventOptionsAttribute.#ctor"></span>
<span id="C:Sansar.Simulation.SimpleScript.OnScriptEventOptionsAttribute()"></span>

```csharp signature
public SimpleScript.OnScriptEventOptionsAttribute()
```



</div>


## Properties

### Message

<div class="api-card">
<span id="P:Sansar.Simulation.SimpleScript.OnScriptEventOptionsAttribute.Message"></span>
<div class="api-badges"><span class="api-badge api-deprecated">Deprecated</span></div>

```csharp signature
[System.Obsolete("SimpleScript is deprecated and will not receive new features. Please use SceneObjectScript or ObjectScript.", false)]
public string Message { get; set; }
```

Set the name of the script event to listen for.

**Value:** [string](https://learn.microsoft.com/dotnet/api/system.string) — The name of the script event message to subscribe to.

<details class="api-remarks"><summary>Remarks</summary>

If Message is not set then OnScriptEvent will receive events with the name of the script class. In the following example it will receive events named &quot;MySimpleScript&quot;

```csharp
// Listen for script events named "MyEvent"
public class MySimpleScript : SimpleScript
{
    protected override void OnScriptEvent(ScriptEventData data)
    {
        // Will get script events named "MySimpleScript"
    }
}
```

</details>

<details class="api-example" open><summary>Example</summary>

```csharp
// Listen for script events "MyEvent"
[OnScriptEventOptions(Message="MyEvent")]
protected override void OnScriptEvent(ScriptEventData data)
```

</details>

</div>




<p class="api-generated" data-pagefind-ignore>Generated from the Sansar 47.10.0 client ScriptApi snapshot.</p>