This document relates to both MonoBehaviour and ECS workflows.

A snapshot is a representation of the state of a simulated world at some point in time. It stores each entity (as long as the entity has the Persistence component) and the values of the entity’s components’ properties.

You use a snapshot as the starting point for your world when you deploy, locally or to the cloud.

How to create a snapshot

You set up snapshots through code and generate them through your Unity Editor.

Set up the snapshot

To do this, look at the Playground project which comes with the GDK for Unity.

In the project’s Editor/SnapshotGenerator folder, there is a simple example of generating a snapshot through code.

You can use this as a base for your own project’s snapshot generation by copying the file to the same folder in your own project and editing the SnapshotGenerator class to add SpatialOS entities to a snapshot.

Generate the snapshot

To generate the snapshot, in your Unity Editor menu: SpatialOS > Generate snapshot to open the snapshot generator window, then select Generate snapshot there.

This saves the generated snapshot to snapshots/default.snapshot, which is where SpatialOS expects to find it unless explicitly told to use another path when you start the deployment.

How to start a deployment from a snapshot

You can start local or cloud deployments using the spatial local launch and spatial cloud launch commands respectively - see the documentation on Deploying your game for details.

Both of these commands can take the optional command line parameter --snapshot=<path>. This starts the deployment with the snapshot at the given path instead of the default snapshots/default.snapshot.

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums