Table of Contents

Class SceneSearchExtensions

Namespace
Stride.CommunityToolkit.Engine
Assembly
Stride.CommunityToolkit.dll

Finds components anywhere in a scene or in the whole running game, the scene-wide counterpart of EntitySearchExtensions.

public static class SceneSearchExtensions
Inheritance
SceneSearchExtensions

Remarks

These walk every entity each time they are called, so they are for a lookup at start or on an event, not for every frame. A manager that many scripts need is better registered once as a service and read back with Services.GetService<T>(). Disabled components are included; filter on Enabled where that matters.

Methods

GetComponentInScene<T>(Scene, bool)

The first component of type T in the scene, or null.

public static T? GetComponentInScene<T>(this Scene scene, bool includeChildScenes = true) where T : EntityComponent

Parameters

scene Scene

The scene to search.

includeChildScenes bool

Whether the scenes under Children are searched as well.

Returns

T

The first match in scene order, or null.

Type Parameters

T

The component type; derived types match too.

GetComponentInScene<T>(IGame)

The first component of type T anywhere in the running game, or null.

public static T? GetComponentInScene<T>(this IGame game) where T : EntityComponent

Parameters

game IGame

The game.

Returns

T

The first match, or null.

Type Parameters

T

The component type; derived types match too.

GetComponentsInScene<T>(Scene, bool)

Every component of type T on any entity of the scene, its children and, by default, its child scenes.

public static IEnumerable<T> GetComponentsInScene<T>(this Scene scene, bool includeChildScenes = true) where T : EntityComponent

Parameters

scene Scene

The scene to search.

includeChildScenes bool

Whether the scenes under Children are searched as well.

Returns

IEnumerable<T>

The components, in scene order; empty when there are none.

Type Parameters

T

The component type; derived types match too.

GetComponentsInScene<T>(IGame)

Every component of type T on any entity the game is running, across every loaded scene.

public static IEnumerable<T> GetComponentsInScene<T>(this IGame game) where T : EntityComponent

Parameters

game IGame

The game.

Returns

IEnumerable<T>

The components, in the order the engine registered their entities; empty when there are none.

Type Parameters

T

The component type; derived types match too.

Remarks

Reads the scene instance, so it covers every scene that is loaded, child scenes included, and only entities that are in a scene: an entity built but not yet added is not found.