Scripts

Scripts are units of code that handle game events, respond to user input, and control entities. In short, scripts make games interactive by adding gameplay.

You use scripts by adding them to entities in the scene as components. Xenko loads a script when the entity it is added to is loaded in the scene.

Xenko scripts are written in C#. You can edit scripts in Game Studio or another IDE (such as visual Studio). Scripts are debugged in Visual Studio.

Scripts

Note

Explaining C# is out of the scope of this documentation.

Scripts have access to the main modules of the Xenko engine:

  • Audio: the audio system
  • Content: loads and saves content from assets
  • DebugText: prints debug text
  • EffectSystem: loads and compiles effects and shaders
  • Game: accesses all information related to your game
  • GraphicsDevice: low-level graphics device to create GPU resources
  • Input: keyboard, mouse and gamepad states and events
  • Log: logs messages and errors from scripts
  • SceneSystem: the currently displayed scene
  • Script: accesses the script manager to schedule or wait for the termination of scripts
  • Services: a registry of services you can use to register your own services
  • SpriteAnimation: animates sprites
  • Streaming: streams contentYou can still use standard C# classes in Xenko, but these aren't called scripts and you can't attach them to entities in Game Studio.

In this section