Skip to content

Get Sansar

Script API

ObjectPrivate

Where: Client
More page actions

For the complete documentation index, see llms.txt. This page is also available as Markdown.

Interface to an object in a Cluster in the Scene.

public class ObjectPrivate : Sansar.Script.InstanceInterface

Remarks

Provides basic information about an object.

Members at a glance

KindMembers
PropertiesForwardVector · InitialPosition · InitialRotation · IsMovable · Mover · Name · ObjectId · Position · RightVector · Rotation · UpVector
MethodsAddInteraction · FindScripts · GetComponent · GetComponentCount · LookupScripts · ToString · TryGetComponent · TryGetFirstComponent

Properties

ForwardVector

public Sansar.Vector ForwardVector { get; }

The forward vector of the ObjectPrivate in the world frame.

Value: Sansar.Vector — A normalized vector.

InitialPosition

public Sansar.Vector InitialPosition { get; }

The position of the ObjectPrivate in world frame before simulation started.

InitialRotation

public Sansar.Quaternion InitialRotation { get; }

The rotation of the ObjectPrivate in world frame before simulation started.

IsMovable

Added in 32.0.0
public bool IsMovable { get; }

Mover

Added in 32.0.0
public Mover Mover { get; }

Name

Added in 31.1.0
public string Name { get; }

This ObjectPrivate name, as specified in the editor.

ObjectId

public Sansar.Script.ObjectId ObjectId { get; }

This ObjectPrivate Id. Unique to this Scene.

Position

public Sansar.Vector Position { get; }

The current position of the ObjectPrivate in world frame.

RightVector

public Sansar.Vector RightVector { get; }

The right vector of the ObjectPrivate in the world frame.

Value: Sansar.Vector — A normalized vector.

Rotation

public Sansar.Quaternion Rotation { get; }

The current rotation of the ObjectPrivate in the world frame.

UpVector

public Sansar.Vector UpVector { get; }

The up vector of the ObjectPrivate in the world frame.

Value: Sansar.Vector — A normalized vector.

Methods

AddInteraction

public void AddInteraction(string prompt, bool enabled)

Add an Interaction to the object to make it clickable.

ParameterTypeDescription
promptstringThe string prompt to show on hover, leave blank to only highlight the object.
enabledboolWhether or not the interaction is enabled.
Remarks

The ObjectPrivate.AddInteractionData will include the Interaction object which can be subscribed to.

public void AddInteraction(     string prompt,     bool enabled,     Action<ObjectPrivate.AddInteractionData> handler )

Add an Interaction to the object to make it clickable.

ParameterTypeDescription
promptstringThe string prompt to show on hover, leave blank to only highlight the object.
enabledboolWhether or not the interaction is enabled.
handlerAction<ObjectPrivate.AddInteractionData>Handler to be called when the event completes.
Remarks

The ObjectPrivate.AddInteractionData will include the Interaction object which can be subscribed to.

FindScripts

Added in 32.0.0
[Sansar.Script.NonReflective] [System.Runtime.CompilerServices.IteratorStateMachine(typeof(Sansar.Simulation.ObjectPrivate/<FindScripts>d__52`1))] public IEnumerable<TInterface> FindScripts<TInterface>() where TInterface : class

Looks up scripts on this ObjectPrivate that match the interface type.

Type parameters: TInterface: The interface to find.

Returns: IEnumerable<TInterface> — An IEnumerable which contains all scripts of the given type name on this ObjectPrivate that match the given interface.

Remarks

The name given corresponds to the Type.FullName of the main script class. Multiple scripts may define unrelated types of the same name, but only registered scripts that match the interface of TInterface will be returned.

[Sansar.Script.NonReflective] [System.Runtime.CompilerServices.IteratorStateMachine(typeof(Sansar.Simulation.ObjectPrivate/<FindScripts>d__51`1))] public IEnumerable<TInterface> FindScripts<TInterface>(     string name ) where TInterface : class

Looks up scripts on this ObjectPrivate that match the interface type by class name.

ParameterTypeDescription
namestringThe type name of the script’s class to find.

Type parameters: TInterface: The interface to find.

Returns: IEnumerable<TInterface> — An IEnumerable which contains all scripts of the given type name on this ObjectPrivate that match the given interface.

Remarks

The name given corresponds to the Type.FullName of the main script class. Multiple scripts may define unrelated types of the same name, but only registered scripts that match the interface of TInterface will be returned.

GetComponent

public object GetComponent(ComponentType componentType, uint index)

Get interfaces to the components that are available at runtime.

ParameterTypeDescription
componentTypeComponentTypeComponentType.
indexuintuint32 index

Returns: object

GetComponentCount

public uint GetComponentCount(ComponentType componentType)

Get the number of components of a particular component type. ComponentType

ParameterTypeDescription
componentTypeComponentTypeComponentType

Returns: uint

LookupScripts

public object[] LookupScripts()

Get handles to the scripts on the ObjectPrivate

Returns: object[] — object [] of Objects of the scripts on the ObjectPrivate

Remarks

The returned Objects are the created script types. For example if a script on the object is public MyTestObject : ObjectScript then the Objects in the array will be of type MyTestObject.

ToString

public override string ToString()

A string representation of this object.

Returns: string — A string representation of this object.

Remarks

The format of this string may change between releases.

TryGetComponent

public bool TryGetComponent<ComponentClass>(     uint index,     out ComponentClass component ) where ComponentClass : class

Try to get a component of a particular type from this ObjectPrivate

ParameterTypeDescription
indexuintThe index of this component type to get. zero based index.
componentComponentClassThe component out parameter of the correct type to get.

Type parameters: ComponentClass: The component type. AnimationComponent RigidBodyComponent

Returns: bool — True if a component of the correct type at index is found, false otherwise.

TryGetFirstComponent

public bool TryGetFirstComponent<ComponentClass>(     out ComponentClass component ) where ComponentClass : class

Try to get the first component of a specific type on this ObjectPrivate

ParameterTypeDescription
componentComponentClassOut parameter of the correct component type.

Type parameters: ComponentClass: The component type. AnimationComponent and RigidBodyComponent

Returns: bool — Returns true if able to get a component of the correct type on this ObjectPrivate.

Used in examples

…and 43 more examples in the snapshot.

Generated from the Sansar 47.10.0 client ScriptApi snapshot.