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 typeT, ornull.GetComponents<T>()- Every component of typeTon the entity.TryGetComponent<T>()- TheTryform, 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 settingScenetonull.
Camera controllers
These are the entity-level counterparts of the Game extensions; use them when you already hold the camera entity.
Add2DCameraController()- Attaches the interactive 2D camera script, giving pan and zoom.Add3DCameraController()- Attaches the interactive 3D camera script, giving free-look movement and an on-screen key reminder.
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.