menu_bookDocumentation

Custom Snapshot Data: INetworkSnapshot for s&box Joining Client Data Transfer

calendar_today May 20, 2026 schedule ~1 min read person PatrickJr verified 50

s&box Components can write and read custom data during the network snapshot process by implementing Component.INetworkSnapshot. The snapshot is sent to clients when they join a s&box multiplayer session. This is useful for serializing custom world data like voxels that doesn't fit into standard [Sync] properties.

Writing Snapshot Data

Override WriteSnapshot to serialize custom data into the s&box network snapshot:

CSHARP
private byte[] MyVoxelData { get; set; }

void INetworkSnapshot.WriteSnapshot( ref ByteStream writer )
{
    writer.Write( MyVoxelData.Length );
    writer.WriteArray( MyVoxelData );
}

Reading Snapshot Data

Override ReadSnapshot to deserialize on the joining client. The s&box loading screen waits for the returned Task to complete:

CSHARP
void INetworkSnapshot.ReadSnapshot( ref ByteStream reader )
{
    var length = reader.Read<int>();
    MyVoxelData = reader.ReadArray<byte>( length ).ToArray();
}

protected override Task OnLoad()
{
    await LoadVoxelWorld( MyVoxelData );
}

This is ideal for large custom data (voxel worlds, procedural terrain, custom map data) that needs to be sent to joining clients as part of the initial s&box scene state, beyond what [Sync] properties and NetworkSpawn handle.

Was this helpful?