Table of Contents

Script Extensions

Extension methods for ScriptComponent, in the Stride.CommunityToolkit.Engine namespace. Mostly shortcuts for things a script reaches for on almost every frame.

  • DeltaTime() - Seconds since the last update, instead of writing Game.UpdateTime.Elapsed.TotalSeconds out in full.
  • GetCamera() - Gets the camera bound to the graphics compositor slot named Main, or to the slot named by cameraName. Returns null when no slot matches.
  • GetFirstCamera() - Gets the first camera in the graphics compositor whatever its slot is called, which is usually what you want when there is only one. Returns null when the compositor has no camera slot.
Note

These look the camera up by its graphics compositor slot rather than by searching the scene, so they find the camera that is actually being rendered from. A slot is bound a frame or two after the game starts, so a script's first updates may get null.

See also