Schema explained

While the schema is a central concept in coherence, most developers won't need to worry about how it works internally, as the coherence SDK automates most of the work involved.

This article is only interesting to those who want to understand more about the internals of how schemas work in coherence.

The schema is a text file defining the structure of the game world from the network's point of view. The schema is shared between the Replication Server, Simulators and Game Clients. The world is generally divided in components and archetypes.

In other words, the schema defines what, how much, how fast and how precisely data is being exchanged between clients and the Replication Server.

The schema file has two uses in your project:

  1. As a basis for code generation, creating various structs and methods that can be used in your project to communicate with the Replication Server.

  2. As a description for the Replication Server, telling it how the data in your project looks like – to receive, store, and send this data to its Clients.

When using MonoBehaviours and CoherenceSync you often don't need to interact with the schema directly. Here's an example of a small schema:

component Player
  name String64
  score Int
component Enemy
  speed Float
  hp Int
  poisonous Bool

To learn more about the types and definitions available in a schema, see the specification.

If you're unsure where schema files are located, you can easily search through the project using Unity's project search window, witht:Coherence.SchemaAsset

Last updated