Get SpatialOS

Sites

Menu

Build after you make changes

You don’t need to build the whole of a SpatialOS project at the same time. What you build depends on what changes you’ve made to it:

For a handy guide to what to build when in Unity, see this cheat sheet:

Unity build cheat sheet

Changes to the schema

From the command line

Any time you change the schema (for example, add or change a component):

  1. Generate code from the schema:

    • To generate code for all workers to use, run spatial worker codegen
    • To generate code for just one worker type, run spatial worker codegen <worker type>

      This runs the ‘codegen’ task for the worker. See build configuration for details.

  2. Fix code references.

  3. Run spatial worker build <worker type> for any relevant workers.

You can then use your IDE to modify your code that uses the generated code.

From Unity

When you change any components that are synchronized with a Unity worker:

  1. In the Unity Editor, open the SpatialOS window (Window > SpatialOS).
  2. To generate the code for Unity to use, under Generate from schema, click Build.
  3. To build your workers, under Workers, click Build.

In the seed snapshot

When you run a local or remote deployment, it starts from a snapshot of the world (sometimes called the “seed snapshot”). If you change the schema, you’ll need to migrate your seed snapshot to the new schema, or generate a new seed snapshot.

You can manipulate the snapshot using the worker SDKs. See the docs for C++, C#, or Java for details.

Changes in Unity

From Unity

There are a few different types of building: exporting prefabs, building workers, and building your seed snapshot.

Export prefabs

You must export prefabs if you modify a prefab directly by:

  • adding a component,
  • removing a component, or
  • changing a property on a component

To export prefabs, in the SpatialOS window (Window > SpatialOS), under Entity prefabs, click Build all.

You only need to do this if the change you’re making apply to the Unity worker whose scene is not currently open.

Build workers

You must build workers if you:

  • modify code that runs on the Unity scene not currently loaded in the editor (usually the UnityWorker), or,
  • modify a preprocessor that changes what scripts are on the Unity scene not currently loaded in the editor (usually the UnityWorker)
  • want to see changes in a built-out worker (rather than running the worker from the Unity scene)

To build workers, in the SpatialOS window (Window > SpatialOS), under Workers, click Build.

Update the seed snapshot

This only applies if you start your deployments from a seed snapshot.

You must update the seed snapshot (or generate a new one) if you make any changes that affect what’s in the snapshot. This includes (but isn’t limited to):

  • adding or removing entities in the initial state (by changing the code which adds them)
  • changing the number of entities in the initial state (by changing the code which adds them)
  • changing the template (used to spawn an entity) of any entity that’s in the seed snapshot, including
    • adding components to the entity
    • removing components from the entity

To update the seed snapshot, use the worker SDKs to manipulate it. For details, see the API documentation:

From the command line

To build Unity changes from the command line:

  1. Make sure the Unity Editor is closed.

    If it’s not, it’ll cause build errors.

  2. In the root directory, run spatial worker build UnityWorker UnityClient --target=development.

    This is the same as using the “Build development workers” menu in Unity.

    Or, to build workers for deployment, run spatial worker build UnityWorker UnityClient --target=deployment.

Changes to other workers

Note: Make sure the Unity Editor is closed when you run spatial worker build. If it’s not, it’ll cause build errors.

From the command line

When you’ve made a change to the code of your worker, run spatial worker build <worker type>. This runs the ‘build’ task for the worker, which normally puts the resulting assets within build/assembly. See build configuration for details.

Cleaning

To clean the results of code generation and build, run spatial worker clean <worker type>. This runs the ‘clean’ task for the worker. See build configuration for details.

To clean the whole project, run spatial worker clean. This also removes the build directory at the root of your project.

Next steps

When you’re ready, deploy your project to the cloud.

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums