Interface to an object in a Cluster in the Scene.
public class ObjectPrivate : Sansar.Script.InstanceInterfaceRemarks
Provides basic information about an object.
Members at a glance
| Kind | Members |
|---|---|
| Properties | ForwardVector · InitialPosition · InitialRotation · IsMovable · Mover · Name · ObjectId · Position · RightVector · Rotation · UpVector |
| Methods | AddInteraction · 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
public bool IsMovable { get; }Mover
public Mover Mover { get; }Name
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.
| Parameter | Type | Description |
|---|---|---|
prompt | string | The string prompt to show on hover, leave blank to only highlight the object. |
enabled | bool | Whether 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.
| Parameter | Type | Description |
|---|---|---|
prompt | string | The string prompt to show on hover, leave blank to only highlight the object. |
enabled | bool | Whether or not the interaction is enabled. |
handler | Action<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
[Sansar.Script.NonReflective]
[System.Runtime.CompilerServices.IteratorStateMachine(typeof(Sansar.Simulation.ObjectPrivate/<FindScripts>d__52`1))]
public IEnumerable<TInterface> FindScripts<TInterface>() where TInterface : classLooks 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 : classLooks up scripts on this ObjectPrivate that match the interface type by class name.
| Parameter | Type | Description |
|---|---|---|
name | string | The 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.
| Parameter | Type | Description |
|---|---|---|
componentType | ComponentType | ComponentType. |
index | uint | uint32 index |
Returns: object
GetComponentCount
public uint GetComponentCount(ComponentType componentType)Get the number of components of a particular component type. ComponentType
| Parameter | Type | Description |
|---|---|---|
componentType | ComponentType | ComponentType |
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 : classTry to get a component of a particular type from this ObjectPrivate
| Parameter | Type | Description |
|---|---|---|
index | uint | The index of this component type to get. zero based index. |
component | ComponentClass | The 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 : classTry to get the first component of a specific type on this ObjectPrivate
| Parameter | Type | Description |
|---|---|---|
component | ComponentClass | Out 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
- FollowThePath.cs
- MoverExample1.cs
- MoverExample2.cs
- MoverExample3.cs
- RandomMovement.cs
- ReflectiveDetectorExample.cs
- StatsExample.cs
- AgentGravityExample.cs
- AgentScaleExample.cs
- AnimationExample.cs
- BanHammerExample.cs
CameraShakeExample.cs
…and 43 more examples in the snapshot.
Generated from the Sansar 47.10.0 client ScriptApi snapshot.