Table of Contents

Entity Extensions

Extension methods for Entity, in the Stride.CommunityToolkit.Engine namespace. They cover the four things you end up doing to an entity constantly: getting components off it, finding it again, attaching a controller, and drawing a gizmo on it.

Components

  • GetComponent<T>() - The first component of type T, or null.
  • GetComponents<T>() - Every component of type T on the entity.
  • TryGetComponent<T>() - The Try form, for when a missing component is expected rather than a bug.
  • GetComponentInChildren<T>() - Searches the entity's descendants, which is where the component usually is on an imported model.
  • Get<T1, T2, …>() - Fetches several components in one pass and returns them as a tuple, so you can deconstruct them into named locals. Overloads exist for two through sixteen types.
var (model, light) = entity.Get<ModelComponent, LightComponent>();

Finding entities

  • FindEntity() - Finds a direct child by name.
  • FindEntityRecursive() - Searches the whole subtree, not only the immediate children.
  • WorldPosition() - The entity's position in world space rather than relative to its parent, updating the transform hierarchy first unless you ask it not to.
  • Remove() - Takes the entity out of its scene by setting Scene to null.

Camera controllers

These are the entity-level counterparts of the Game extensions; use them when you already hold the camera entity.

See Camera Controllers for the keys, the on-screen help and every option on both scripts.

Gizmos

  • AddGizmo() - Draws a translation gizmo at the entity, with optional per-axis colours and axis letters.
  • AddLightDirectionalGizmo() - Draws which way a directional light is pointing, which is otherwise invisible.