Out of the box, coherence will use C# Reflection to sync all the data at runtime. This is a great way to get started but it is very costly performance-wise.
For optimal runtime performance, we need to create a schema and perform code generation specific to our project.
coherence offers an automatic way of doing that called baking.
Learn more about this in the How does coherence work section.
Click on coherence -> Bake Schemas
.
This will go through all CoherenceSync
components in the project and generate a schema file based on the selected variables, commands and other settings. It will also take into account any CoherenceArchetype
components.
For every prefab with a CoherenceSync
object, the baking process will generate a bespoke C# file in the coherence/baked
folder in the project.
Adding that file to the prefab will make that prefab use bespoke generated code instead of C# reflection.
Once the Schema has been baked, you will be able to activate the baked script in the Configuration section of the CoherenceSync component.
The name of the baked script will be CoherenceSync[prefabName]
.