Get SpatialOS

Sites

Menu

Schema introduction

The schema is where you define all the components in your SpatialOS world.

Components are a set of persistent properties that make up entities: the main concept of a SpatialOS world. Components can have:

  • properties that describe persistent values that change over time

  • events that describe transient things that have happened to an entity

  • commands that describe things that other entities can ask this entity to do

To define the components that entities can have, create .schema files, written in schemalang (SpatialOS’s language for writing component schemas). Schema files are stored in the schema/ directory.

SpatialOS uses the schema to generate code in various languages (including C#, C++, and Java). You can use this generated code in your worker code to interact with entities: to read from their components, and to make changes to them.

Writing .schema files

For information about writing schema files, see the schemalang reference page.

Generating code from the schema

Use the spatial worker codegen command to compile the schema into generated code (in C#, C++, Java, and for the Unity SDK).

This code is used by workers to interact with entities: to read from their components, and to make changes to them.

For details on how to use the generated code to read from components, see the language-specific docs:

For details on how to use the generated code to make changes to components, see the language-specific docs:

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums