Scene
Summary
Represents the primary scene graph container managing actor hierarchies, components, and execution lifecycles.
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.
Important
Instances of this class manage native engine allocations and MUST be disposed manually.
Definition
Namespace: SDT4.Managed.Core
Assembly: SDT4.Managed.Core.dll
class Scene
Inheritance:
Object ➔ Scene
Implements:
IDisposable, IDisposeTracker<Scene>
Fields
| Name | Type | Description |
|---|---|---|
Properties
| Name | Type | Description |
|---|---|---|
public get; NativeHandle |
IntPtr | Gets the pointer to the underlying native engine scene. |
public get; Name |
String | Gets the display name of this scene, or |
NativeHandle Remarks
Warning
Intended for internal engine interop; direct access by user scripts is typically unnecessary.
Methods
public static Scene CreateEmptyScene(String? name)
Summary: Creates a new empty scene containing no actors.
Parameters:
name(String?): An optional debug or display name to assign to the scene.
Returns:
public Void Start()
Summary: Starts the scene runtime, transitioning all active actors and scripts into their execution state.
public Void Stop()
Summary: Stops the scene runtime, terminating ticking and active script execution.
public Void ParentActor(ActorHandle child, Nullable<ActorHandle> parent)
Summary: Attaches a child actor to a specified parent actor in the hierarchy. If the child is already parented, it is unparented first.
Parameters:
-
child(ActorHandle): The child actor handle to parent. -
parent(Nullable<ActorHandle>): The target parent actor handle, orto detach the child to the scene root.
public ActorHandle CreateEmptyActor(String? name)
Summary: Spawns a new empty actor within the root scope of this scene.
Parameters:
name(String?): An optional name to assign to the actor.
Returns:
- ActorHandle: The handle of the newly created actor.
public Nullable<ActorHandle> CreatePrefabActor(PrefabAsset prefab, String? name, Object? payload)
Summary: Instantiates an actor hierarchy from a prefab asset into this scene, optionally initialising its attached script.
Parameters:
-
prefab(PrefabAsset): The prefab asset to instantiate. -
name(String?): An optional name override for the root actor; if, default naming is used. -
payload(Object?): An optional script payload forwarded to the ActorScript.OnCreate hook.
Returns:
- Nullable<ActorHandle>: A valid ActorHandle if instantiation succeeded; otherwise,
if creation was vetoed.
public Nullable<ActorHandle> GetActorFromId(UInt64 id)
Summary: Resolves an actor handle using an integer identifier relative to the scene root.
Parameters:
id(UInt64): The root-relative identifier to query.
Returns:
- Nullable<ActorHandle>: The resolved ActorHandle, or
if no matching actor exists.
public Nullable<ActorHandle> GetActorFromGuid(Guid guid)
Summary: Resolves an actor handle matching a globally unique identifier.
Parameters:
guid(Guid): The globally unique identifier to query.
Returns:
- Nullable<ActorHandle>: The resolved ActorHandle, or
if no matching actor exists.
public IEnumerable<TComponent> EnumerateComponents<TComponent>()
Summary: Enumerates all active components of the specified type across all actors in this scene.
Returns:
- IEnumerable<TComponent>: An enumerable sequence of matching component instances.
public IEnumerable<ActorHandle> EnumerateActorsByName(String name)
Summary: Enumerates all actor handles in this scene that match a specified name string.
Parameters:
name(String): The name string to match.
Returns:
- IEnumerable<ActorHandle>: An enumerable sequence of matching ActorHandle instances.
public IEnumerable<TActor> EnumerateActorsWithScript<TActor>()
Summary: Enumerates all active actor scripts in this scene matching the specified script type.
Returns:
- IEnumerable<TActor>: An enumerable sequence of matching actor script instances.
public Void KillActor(ActorHandle actor)
Summary: Destroys the specified actor and cleans up its components, hierarchy bindings, and script instances.
Parameters:
actor(ActorHandle): The actor handle to destroy.
public Void Dispose()
Summary: Releases all unmanaged scene resources and destroys all associated actors.
public virtual Boolean Equals(Object? obj)
Summary: Determines whether the specified object is a Scene referencing the same native scene instance.
Parameters:
obj(Object?): The object to compare with this instance.
Returns:
public virtual Int32 GetHashCode()
Summary: Returns the hash code for this scene based on its native pointer address.
Returns:
- Int32: A 32-bit signed integer hash code.
public virtual String ToString()
Summary: Returns a formatted string representation of this scene.
Returns:
- String: A string identifying the scene pointer and name.