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.
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