SimpleScript

SimpleScript Class

Extend SimpleScript to create a script that can be used on content that is natively in the scene. This is the primary script type in Sansar.

Syntax

[Sansar.Script.Interface]
[System.Obsolete("SimpleScript is deprecated and will not receive new features. Please use SceneObjectScript or ObjectScript.", true)]
public abstract class SimpleScript : Sansar.Script.ScriptBase

Remarks

Use SimpleScript.ObjectPrivate to access the Object the script is on.

Use SimpleScript.ScenePrivate to access the Scene the object is in.

Override SimpleScript.OnAddUser(AgentPrivate) to handle AddUser events.

C# Example
            protected override OnAddUser(AgentPrivate agent)
            {
                agent.SendChat($"Welcome to the {ScenePrivate.SceneInfo.ExperienceName} scene!");
            }

Override SimpleScript.OnRemoveUser(AgentInfo) to handle AddUser events.

C# Example
            protected override OnRemoveUser(AgentInfo agent)
            {
                Log.Write($"{agent.Name} has left the region.");
            }

Override SimpleScript.OnTimer to do something at regular intervals.

C# Example
            protected override OnTimer()
            {
                RigidBodyComponent?.SetPosition(ObjectPrivate?.InitialPosition);
            }

Override SimpleScript.OnChat(ChatData) to handle Chat events when users or scripts chat.

C# Example
            protected override OnChat(ChatData data)
            {
                AgentPrivate agent = ScenePrivate.FindAgent(data.SourceId);
                if (agent != null && agent.AgentInfo.AvatarUuid == ScenePrivate.SceneInfo.AvatarUuid))
                {
                   Log.Write($"Scene owner {agent.AgentInfo.Name} said {data.Message}");
                }
            }

Override SimpleScript.OnCollision(CollisionData) to handle Collision events with the object this script is on.

C# Example
            protected override OnCollision(CollisionData data)
            {
                Log.Write($"Bumped {data.HitObject.ObjectId}");
            }

Override SimpleScript.OnScriptEvent(Sansar.Script.ScriptId, object) to handle ScriptEvent events from other scripts.

C# Example
            protected override OnScriptEvent(AgentPrivate agent)
            {
                ISimpleScriptEvent simple = data.Data.As<ISimpleScriptEvent>();
                Log.Write($"Received message {data.Message} event with data {simple.Value}");
            }

Override Sansar.Script.SimpleScript.SimpleInit() for more advanced script initialization.

C# Example
              

Requirements

Namespace: Sansar.Simulation
Assembly: Sansar.Simulation (in Sansar.Simulation.dll)
Assembly Versions: 1.1.0.0

Members

See Also: Inherited members from Sansar.Script.ScriptBase.

Protected Constructors

 
This constructor is called before any properties have been set. Override Sansar.Script.SimpleScript.SimpleInit() to initialize the script after properties have been set and events setup.

Public Properties

 
Log Sansar.Script.Log . Gets the script console. (Inherited from Sansar.Script.ScriptBase.)
 
Memory Sansar.Script.Memory . Memory information for the pool this script is in. (Inherited from Sansar.Script.ScriptBase.)
 
ObjectPrivate ObjectPrivate . The ObjectPrivate this script is attached to if it is attached to an object.
 
ScenePrivate ScenePrivate . The Scene API for the Scene this script is a part of if the script is attached to scene content.
 
Script Sansar.Script.ScriptHandle . Script handle to this script. (Inherited from Sansar.Script.ScriptBase.)

Protected Properties

[read-only]
 
AllowedContexts Sansar.Script.Reflective.Context . Internal Use Only. Overridden by subclasses to return only those contexts requested which are allowed for that type of script. (Inherited from Sansar.Script.Reflective.)
[read-only]
 
CurrentCoroutine Sansar.Script.ICoroutine . Gets the ICoroutine interface for the current coroutine. (Inherited from Sansar.Script.ScriptBase.)
[read-only]
 
MaxCoroutines int . The maximum number of coroutines that a single script can run. (Inherited from Sansar.Script.ScriptBase.)
[read-only]
 
PendingEventCount int . The number of events currently waiting to be processed. (Inherited from Sansar.Script.ScriptBase.)
[read-only]
 
ReflectiveContexts Sansar.Script.Reflective.Context . Override ReflectiveContexts to limit which contexts this Reflective interface is available in when registered with. (Inherited from Sansar.Script.Reflective.)
[read-only]
 
ReflectiveName string . Override ReflectiveName to change which name this class will be registered as in the Reflective system. (Inherited from Sansar.Script.Reflective.)
[read-only]
 
RigidBodyComponent RigidBodyComponent . The first RigidBodyComponent on ObjectPrivate

Public Methods

 
AsInterface<TInterface> () : TInterface
Returns a TInterface object if one can be created, null otherwise (Inherited from Sansar.Script.Reflective.)
 
FullInterface (string) : string
Generates a string which shows all the members which can be reflected. (Inherited from Sansar.Script.Reflective.)
override
Init ()
Init() initializes all event subscriptions for the overridable methods in SimpleScript
abstract
Init ()
Init() is called after all interfaces have been initialized. (Inherited from Sansar.Script.ScriptBase.)
 
Register ()
Register this object to be found with ScenePrivate.FindReflective(string) (Inherited from Sansar.Script.Reflective.)
 
Unregister ()
Unregister this object so it will not be found with ScenePrivate.FindReflective(string) (Inherited from Sansar.Script.Reflective.)
 
Yield ()
Yield to let other coroutines or events run. (Inherited from Sansar.Script.ScriptBase.)

Protected Methods

 
GetAllCoroutines () : IReadOnlyList<Sansar.Script.ICoroutine>
A list of all coroutines for this script. (Inherited from Sansar.Script.ScriptBase.)
 
GetCoroutineCount () : int
The total number of coroutines running on this script. (Inherited from Sansar.Script.ScriptBase.)
 
GetSubscription (string) : Sansar.Script.IEventSubscription
Get the IEventSubscription for any of the registered event subscription methods
 
Lock (object) : IDisposable
Use to create a critical section with a using statement, ensuring that no other coroutines or scripts (via Reflective) may enter this code section while one coroutine or script is in it. (Inherited from Sansar.Script.ScriptBase.)
 
OnAddUser (AgentPrivate)
Code in OnAddUser will run whenever a user enters the scene.
 
OnChat (ChatData)
Code in OnChat will run whenever chat is heard.
 
OnCollision (CollisionData)
Receive events whenever the object this script is on collides with something or someone.
 
OnRemoveUser (AgentInfo)
Code in OnRemoveUser will run whenever a user leaves the scene.
 
OnScriptEvent (Sansar.Script.ScriptId, object)
Receive events from other scripts.
 
OnTimer ()
Code in OnTimer will run at regular intervals.
 
PostScriptEvent (string)
Post the event for all scripts. (Inherited from Sansar.Script.ScriptBase.)
 
PostScriptEvent (string, Sansar.Script.Reflective)
Post the event for all scripts. (Inherited from Sansar.Script.ScriptBase.)
 
PostScriptEvent (Sansar.Script.ScriptId, string, Sansar.Script.Reflective)
Post the event for the target script. (Inherited from Sansar.Script.ScriptBase.)
 
PostSimpleScriptEvent (string, object)
Deprecated. Use Sansar.Script.ScriptBase.PostScriptEvent(Sansar.Script.ScriptId, string, Sansar.Script.Reflective) (Inherited from Sansar.Script.ScriptBase.)
 
PostSimpleScriptEvent (Sansar.Script.ScriptId, string, object)
Deprecated. Use Sansar.Script.ScriptBase.PostScriptEvent(Sansar.Script.ScriptId, string, Sansar.Script.Reflective) (Inherited from Sansar.Script.ScriptBase.)
 
ReleaseLock (object)
Release a lock if held. (Inherited from Sansar.Script.ScriptBase.)
 
SimpleInit ()
Override SimpleInit for script setup, such as subscribing to other events or
 
StartCoroutine (Action, Action<Sansar.Script.OperationCompleteEvent>) : Sansar.Script.ICoroutine
Starts a coroutine on the current script. (Inherited from Sansar.Script.ScriptBase.)
 
StartCoroutine<T> (Action<T>, T, Action<Sansar.Script.OperationCompleteEvent>) : Sansar.Script.ICoroutine
Starts a coroutine on the current script. (Inherited from Sansar.Script.ScriptBase.)
 
StartCoroutine<T,T1> (Action<T, T1>, T, T1, Action<Sansar.Script.OperationCompleteEvent>) : Sansar.Script.ICoroutine
Starts a coroutine on the current script. (Inherited from Sansar.Script.ScriptBase.)
 
StartCoroutine<T,T1,T2> (Action<T, T1, T2>, T, T1, T2, Action<Sansar.Script.OperationCompleteEvent>) : Sansar.Script.ICoroutine
Starts a coroutine on the current script. (Inherited from Sansar.Script.ScriptBase.)
 
StartCoroutine<T,T1,T2,T3> (Action<T, T1, T2, T3>, T, T1, T2, T3, Action<Sansar.Script.OperationCompleteEvent>) : Sansar.Script.ICoroutine
Starts a coroutine on the current script. (Inherited from Sansar.Script.ScriptBase.)
 
SubscribeToScriptEvent (string, Action<Sansar.Script.ScriptEventData>, bool) : Sansar.Script.IEventSubscription
Subscribes to events sent by other scripts (Inherited from Sansar.Script.ScriptBase.)
 
SubscribeToScriptEvent (Sansar.Script.ScriptId, string, Action<Sansar.Script.ScriptEventData>, bool) : Sansar.Script.IEventSubscription
Subscribes to events sent only by a specific script. (Inherited from Sansar.Script.ScriptBase.)
 
Terminate (string)
Terminates this script immediately. (Inherited from Sansar.Script.ScriptBase.)
 
Wait (TimeSpan)
Delays execution of the current coroutine for the specified time. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor (Sansar.Script.ICoroutine)
Block the current coroutine until otherCoroutine finishes. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor (Action<Action<Sansar.Script.OperationCompleteEvent>>) : Sansar.Script.OperationCompleteEvent
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor (Func<Action<Sansar.Script.EventData>, Action<Sansar.Script.CancelData>,System.Boolean,Sansar.Script.IEventSubscription>) : Sansar.Script.EventData
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor (Func<Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>) : Sansar.Script.EventData
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor (Func<Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>, Action) : Sansar.Script.EventData
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<ARG1> (Func<ARG1, Action<Sansar.Script.EventData>, Action<Sansar.Script.CancelData>,System.Boolean,Sansar.Script.IEventSubscription>, ARG1) : Sansar.Script.EventData
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<ARG1> (Func<ARG1, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>, ARG1) : Sansar.Script.EventData
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<ARG1> (Func<ARG1, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>, ARG1, Action) : Sansar.Script.EventData
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<T1> (Action<T1, Action<Sansar.Script.OperationCompleteEvent>>, T1) : Sansar.Script.OperationCompleteEvent
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<ARG1,ARG2> (Func<ARG1, ARG2, Action<Sansar.Script.EventData>, Action<Sansar.Script.CancelData>,System.Boolean,Sansar.Script.IEventSubscription>, ARG1, ARG2) : Sansar.Script.EventData
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<ARG1,ARG2> (Func<ARG1, ARG2, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>, ARG1, ARG2) : Sansar.Script.EventData
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<ARG1,ARG2> (Func<ARG1, ARG2, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>, ARG1, ARG2, Action) : Sansar.Script.EventData
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<T1,T2> (Action<T1, T2, Action<Sansar.Script.OperationCompleteEvent>>, T1, T2) : Sansar.Script.OperationCompleteEvent
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<ARG1,ARG2,ARG3> (Func<ARG1, ARG2, ARG3, Action<Sansar.Script.EventData>, Action<Sansar.Script.CancelData>,System.Boolean,Sansar.Script.IEventSubscription>, ARG1, ARG2, ARG3) : Sansar.Script.EventData
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<ARG1,ARG2,ARG3> (Func<ARG1, ARG2, ARG3, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>, ARG1, ARG2, ARG3) : Sansar.Script.EventData
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<ARG1,ARG2,ARG3> (Func<ARG1, ARG2, ARG3, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>, ARG1, ARG2, ARG3, Action) : Sansar.Script.EventData
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<T1,T2,T3> (Action<T1, T2, T3, Action<Sansar.Script.OperationCompleteEvent>>, T1, T2, T3) : Sansar.Script.OperationCompleteEvent
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<ARG1,ARG2,ARG3,ARG4> (Func<ARG1, ARG2, ARG3, ARG4, Action<Sansar.Script.EventData>, Action<Sansar.Script.CancelData>,System.Boolean,Sansar.Script.IEventSubscription>, ARG1, ARG2, ARG3, ARG4) : Sansar.Script.EventData
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<ARG1,ARG2,ARG3,ARG4> (Func<ARG1, ARG2, ARG3, ARG4, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>, ARG1, ARG2, ARG3, ARG4) : Sansar.Script.EventData
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<ARG1,ARG2,ARG3,ARG4> (Func<ARG1, ARG2, ARG3, ARG4, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>, ARG1, ARG2, ARG3, ARG4, Action) : Sansar.Script.EventData
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<T1,T2,T3,T4> (Action<T1, T2, T3, T4, Action<Sansar.Script.OperationCompleteEvent>>, T1, T2, T3, T4) : Sansar.Script.OperationCompleteEvent
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<ARG1,ARG2,ARG3,ARG4,ARG5> (Func<ARG1, ARG2, ARG3, ARG4, ARG5, Action<Sansar.Script.EventData>, Action<Sansar.Script.CancelData>,System.Boolean,Sansar.Script.IEventSubscription>, ARG1, ARG2, ARG3, ARG4, ARG5) : Sansar.Script.EventData
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<ARG1,ARG2,ARG3,ARG4,ARG5> (Func<ARG1, ARG2, ARG3, ARG4, ARG5, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>, ARG1, ARG2, ARG3, ARG4, ARG5) : Sansar.Script.EventData
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitFor<ARG1,ARG2,ARG3,ARG4,ARG5> (Func<ARG1, ARG2, ARG3, ARG4, ARG5, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription>, ARG1, ARG2, ARG3, ARG4, ARG5, Action) : Sansar.Script.EventData
Use to pause the script until an event happens. (Inherited from Sansar.Script.ScriptBase.)
 
WaitForLock (object)
WaitFor and take a lock on Token (Inherited from Sansar.Script.ScriptBase.)
 
WaitForSignal () : int
Wait the current coroutine until at least 1 signal is sent to it through the ICoroutine interface. (Inherited from Sansar.Script.ScriptBase.)

Member Details

SimpleScript Constructor

This constructor is called before any properties have been set. Override Sansar.Script.SimpleScript.SimpleInit() to initialize the script after properties have been set and events setup.

Syntax

[Sansar.Script.Interface]
[System.Obsolete("SimpleScript is deprecated and will not receive new features. Please use SceneObjectScript or ObjectScript.", false)]
protected SimpleScript ()

Remarks

 

Requirements

Namespace: Sansar.Simulation
Assembly: Sansar.Simulation (in Sansar.Simulation.dll)
Assembly Versions: 1.1.0.0

GetSubscription Method

Get the IEventSubscription for any of the registered event subscription methods

Syntax

protected Sansar.Script.IEventSubscription GetSubscription (string methodName)

Parameters

methodName
The n

Returns

An IEventSubscription interface that can be used to unsubscribe from a registered event.

Remarks

Documentation for this section has not yet been entered.

Example

C# Example
            GetSubscription("OnChat").Unsubscribe();
            

Requirements

Namespace: Sansar.Simulation
Assembly: Sansar.Simulation (in Sansar.Simulation.dll)
Assembly Versions: 1.1.0.0

Init Method

Init() initializes all event subscriptions for the overridable methods in SimpleScript

Syntax

[Sansar.Script.Api]
public override sealed void Init ()

See Also

Remarks

 

Requirements

Namespace: Sansar.Simulation
Assembly: Sansar.Simulation (in Sansar.Simulation.dll)
Assembly Versions: 1.1.0.0

ObjectPrivate Property

The ObjectPrivate this script is attached to if it is attached to an object.

Syntax

[Sansar.Script.NonReflective]
[get: Sansar.Script.Interface]
public ObjectPrivate ObjectPrivate { protected get; set; }

Value

The scene object this script is attached to if it is attached to an object, null otherwise.

Remarks

For AgentScripts this is the Agent's ObjectPrivate of their avatar.

Requirements

Namespace: Sansar.Simulation
Assembly: Sansar.Simulation (in Sansar.Simulation.dll)
Assembly Versions: 1.1.0.0

OnAddUser Method

Code in OnAddUser will run whenever a user enters the scene.

Syntax

[Sansar.Script.Interface]
[System.Obsolete("SimpleScript is deprecated and will not receive new features. Please use SceneObjectScript or ObjectScript.", false)]
protected virtual void OnAddUser (AgentPrivate agent)

See Also

Parameters

agent
The AgentPrivate for the user that has joined the scene.

Remarks

Override OnAddUser to handle events when a user enters the scene.

Example

C# Example
            protected override OnAddUser(AgentPrivate agent)
            {
               agent.SendChat($"Welcome to the {ScenePrivate.SceneInfo.ExperienceName} scene!");
            }
            

Requirements

Namespace: Sansar.Simulation
Assembly: Sansar.Simulation (in Sansar.Simulation.dll)
Assembly Versions: 1.1.0.0

OnChat Method

Code in OnChat will run whenever chat is heard.

Syntax

[Sansar.Script.Interface]
[System.Obsolete("SimpleScript is deprecated and will not receive new features. Please use SceneObjectScript or ObjectScript.", false)]
protected virtual void OnChat (ChatData data)

See Also

Parameters

data
ChatData for the message.

Remarks

Defaults to all chat on the default channel. Use [OnChatOptions] to change the channel or limit the source of the chat.

Requirements

Namespace: Sansar.Simulation
Assembly: Sansar.Simulation (in Sansar.Simulation.dll)
Assembly Versions: 1.1.0.0

OnCollision Method

Receive events whenever the object this script is on collides with something or someone.

Syntax

[Sansar.Script.Interface]
[System.Obsolete("SimpleScript is deprecated and will not receive new features. Please use SceneObjectScript or ObjectScript.", false)]
protected virtual void OnCollision (CollisionData data)

See Also

Parameters

data
The CollisionData about the collision.

Remarks

By default receives events for every collision. Use Sansar.Simulation.SimpleScript.OnCollisionOptionsAttribute to change which types of collision events will trigger OnCollision.

Requirements

Namespace: Sansar.Simulation
Assembly: Sansar.Simulation (in Sansar.Simulation.dll)
Assembly Versions: 1.1.0.0

OnRemoveUser Method

Code in OnRemoveUser will run whenever a user leaves the scene.

Syntax

[Sansar.Script.Interface]
[System.Obsolete("SimpleScript is deprecated and will not receive new features. Please use SceneObjectScript or ObjectScript.", false)]
protected virtual void OnRemoveUser (AgentInfo data)

See Also

Parameters

data
UserData for the user that has left the scene.

Remarks

Override OnAddUser to handle events when a user enters the scene.

Example

C# Example
// This event occurs when a user leaves the scene
            protected override void OnRemoveUser(AgentInfo info)
            {
                Log.Write($"{info.Name} has left the region.");
            }

Requirements

Namespace: Sansar.Simulation
Assembly: Sansar.Simulation (in Sansar.Simulation.dll)
Assembly Versions: 1.1.0.0

OnScriptEvent Method

Receive events from other scripts.

Syntax

[Sansar.Script.Interface]
[System.Obsolete("SimpleScript is deprecated and will not receive new features. Please use SceneObjectScript or ObjectScript.", false)]
protected virtual void OnScriptEvent (Sansar.Script.ScriptId sourceScriptId, object data)

See Also

Parameters

sourceScriptId
The Sansar.Script.ScriptId of the script that sent the message
data
The data sent by another script, as an object.

Remarks

If EventName 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"
C# Example
            public class SimpleExample : SimpleScript
            {
                // Send events to this handler from other simple scripts with: PostScriptEvent("SimpleExample", myVector);
                protected override void OnScriptEvent(object eventData)
                {
                    Vector newPos = eventData as Vector;
                    if (newPos != null) AllPositions.Add(newPos);
                }
            }    
            

To send events to a SimpleScript from a non-simple script, the non-simple script must build a Reflective class that contains a single public object field named Data like this:

C# Example
            class SimpleData : Reflective
            {
                public object Data;
            }
            

Then send the data like this:

C# Example
PostScriptEvent("simpleeventname",new SimpleData {Data = position});

Example

C# 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);
            }
            

Requirements

Namespace: Sansar.Simulation
Assembly: Sansar.Simulation (in Sansar.Simulation.dll)
Assembly Versions: 1.1.0.0

OnTimer Method

Code in OnTimer will run at regular intervals.

Syntax

[Sansar.Script.Interface]
[System.Obsolete("SimpleScript is deprecated and will not receive new features. Please use SceneObjectScript or ObjectScript.", false)]
protected virtual void OnTimer ()

Remarks

Defaults to one call per second. Change the rate with Sansar.Simulation.SimpleScript.OnTimerOptionsAttribute

Example

C# Example
            // Set OnTimer to happen once every minute.
            [OnTimerOptions(Rate=60)]
            protected override void OnTimer()
            

Requirements

Namespace: Sansar.Simulation
Assembly: Sansar.Simulation (in Sansar.Simulation.dll)
Assembly Versions: 1.1.0.0

RigidBodyComponent Property

The first RigidBodyComponent on ObjectPrivate

Syntax

[get: Sansar.Script.Interface]
protected RigidBodyComponent RigidBodyComponent { get; }

Value

The first SimpleScript.RigidBodyComponent on the object this script is attached to.

Remarks

This is a convenience for:
C# Example
            RigidBodyComponent rigidbody;
             if (ObjectPrivate != null && ObjectPrivate.TryGetFirstComponent(out rigidbody))
            {
                // Do something with rigidbody
            }
            

Requirements

Namespace: Sansar.Simulation
Assembly: Sansar.Simulation (in Sansar.Simulation.dll)
Assembly Versions: 1.1.0.0

ScenePrivate Property

The Scene API for the Scene this script is a part of if the script is attached to scene content.

Syntax

[Sansar.Script.NonReflective]
[get: Sansar.Script.Interface]
public ScenePrivate ScenePrivate { protected get; set; }

Value

The Scene API for this scene if this script was attached to scene content, null otherwise.

Remarks

This value will be set before Init is called.

Requirements

Namespace: Sansar.Simulation
Assembly: Sansar.Simulation (in Sansar.Simulation.dll)
Assembly Versions: 1.1.0.0

SimpleInit Method

Override SimpleInit for script setup, such as subscribing to other events or

Syntax

[Sansar.Script.Interface]
[System.Obsolete("SimpleScript is deprecated and will not receive new features. Please use SceneObjectScript or ObjectScript.", false)]
protected virtual void SimpleInit ()

Remarks

SimpleInit is run after events have been set up for overridden methods. Use it to set up more complex subscriptions or otherwise initialize the script.

Requirements

Namespace: Sansar.Simulation
Assembly: Sansar.Simulation (in Sansar.Simulation.dll)
Assembly Versions: 1.1.0.0


Was this article helpful?
0 out of 1 found this helpful
Have more questions? Submit a request

0 Comments

Article is closed for comments.