- Home
- Script API
- Sansar.Simulation
- Classes
- SimpleScript.OnScriptEventOptionsAttribute
Script API
SimpleScript.OnScriptEventOptionsAttribute
Set options for OnScriptEvent events.
[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.SimpleScriptOptionsAttributeRemarks
If EventName is not set then OnScriptEvent will receive events with the name of the script class.
Example
// 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 |
| Properties | Message |
Constructors
OnScriptEventOptionsAttribute
public SimpleScript.OnScriptEventOptionsAttribute()Properties
Message
Deprecated
[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 — The name of the script event message to subscribe to.
Remarks
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 “MySimpleScript”
// Listen for script events named "MyEvent"public class MySimpleScript : SimpleScript{ protected override void OnScriptEvent(ScriptEventData data) { // Will get script events named "MySimpleScript" }}Example
// Listen for script events "MyEvent"[OnScriptEventOptions(Message="MyEvent")]protected override void OnScriptEvent(ScriptEventData data)Generated from the Sansar 47.10.0 client ScriptApi snapshot.