ActorHandle

Summary

Represents a lightweight, zero-allocation handle wrapping an actor in a scene.

Remarks

Danger

All calls made within this class MUST be performed on the Master Thread. See Threads.RunLater on how to safely call this from an asynchronous thread. Failure to comply with this can cause catastrophic failures as the engine is not designed for concurrent scene mutation.

Definition

Namespace: SDT4.Managed.Core
Assembly: SDT4.Managed.Core.dll

struct ActorHandle
Implements:

IEquatable<ActorHandle>

Fields

Name Type Description
public readonly NativeHandle UInt32 Native entity handle.
public readonly Scene Scene Native scene pointer.

Properties

Name Type Description
public get; GlobalId Guid Gets the persistent globally unique identifier of the referenced actor.
public get; ScopeId Guid Gets the unique identifier of the hierarchy scope containing this actor.
public get; LocalId UInt64 Gets the scope-local identifier of the referenced actor.
public get; set; Name String? Gets or sets the display or debug name of the actor, or if unnamed.
public get; IsValid Boolean Gets a value indicating whether the actor is a valid, active instance in the scene.
public get; ScopeRoot ActorHandle Gets the top-most root actor handle in the current hierarchy scope. If the actor is the top most, it will return itself.
public get; Mobility Mobility Gets the mobility state of this actor (e.g. static, stationary, or dynamic).
public get; Parent Nullable<ActorHandle> Gets the handle of this actor's direct parent in the transform hierarchy, or if it has no parent.
public get; Children ActorHandle[] Gets an array of handles representing all direct children of this actor in the hierarchy.
public get; Components IActorComponent[] Gets an array containing all components currently attached to this actor.

Methods

public Boolean HasComponent<TComponent>()

Summary: Determines whether this actor has a component of the specified type attached.

Returns:


public TComponent GetComponent<TComponent>()

Summary: Retrieves the attached component of the specified type.

Returns:


public Boolean TryGetComponent<TComponent>(out TComponent component)

Summary: Attempts to retrieve an attached component of the specified type.

Parameters:

Returns:


public TComponent AddComponent<TComponent>()

Summary: Instantiates and attaches a new component of the specified type to this actor.

Returns:


public Boolean RemoveComponent<TComponent>()

Summary: Removes the component of the specified type from this actor.

Returns:


public Nullable<ActorHandle> GetActorByLocalIdInScope(UInt64 localId)

Summary: Resolves an actor handle within the same hierarchy scope matching a scope-local identifier.

Parameters:

Returns:


public ActorHandle CreateEmptyActorInScope(String? name)

Summary: Spawns a new empty actor belonging to the current actor's hierarchy scope.

Parameters:

Returns:


public Nullable<ActorHandle> CreatePrefabActorInScope(PrefabAsset prefab, String? name, Object? payload)

Summary: Creates an actor from a prefab asset. This will instantiate a new instance of actors from the prefab chain, and optionally initialise a script if the prefab has one. This will insert it within the scope of the current actor.

Parameters:

Returns:


public TActor AsScript<TActor>()

Summary: Resolves the typed script instance associated with this actor if it exists.

Returns:


public Actor AsActor()

Summary: Returns the associated script instance as an Actor, or instantiates a new managed representation if none exists.

Returns:


public virtual Boolean Equals(Object? obj)

Summary: Determines whether the specified object is an ActorHandle and matches this instance.

Parameters:

Returns:


public Boolean Equals(ActorHandle other)

Summary: Determines whether the specified ActorHandle references the same native entity and scene.

Parameters:

Returns:


public virtual Int32 GetHashCode()

Summary: Returns the hash code for this actor handle.

Returns:


public virtual String ToString()

Summary: Returns a formatted string representation of this actor handle.

Returns: