Asset management
In this section we cover how coherence handles loading CoherenceSync
Prefabs into memory and instantiating them when a new remote entity appears on the network.
CoherenceSyncConfig assets
Whenever you start synchronizing one of your Prefabs, either by adding the CoherenceSync
component manually or clicking the Sync with coherence toggle in the Prefab inspector, coherence will create a CoherenceSyncConfig
ScriptableObject to track the existence of this entity, and add it to a registry.
![](https://docs.coherence.io/~gitbook/image?url=https%3A%2F%2F2047761709-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Ffo6vUwbCyyb7fmwjPG0A%252Fuploads%252FHGwGssEDZbwTfwMudF79%252FCoherenceSyncConfig.png%3Falt%3Dmedia%26token%3Dd110d7ef-ce61-4845-8f32-0ecd1de92454&width=768&dpr=4&quality=100&sign=9a7193d5&sv=1)
This object holds information on how a certain type of network entity is loaded and instantiated. As a user, the two main changeable options here are Load via, and Instantiate via.
There is a 1:1 correspondence between a networked Prefab and its CoherenceSyncConfig
object, so you can also edit the related CoherenceSyncConfig
in the inspector of any CoherenceSync
component:
![](https://docs.coherence.io/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2Ffo6vUwbCyyb7fmwjPG0A%2Fblobs%2Fw35wmTRknx3zqs5Z83HC%2FAM%252003%2520Config%2520in%2520Sync.png&width=768&dpr=4&quality=100&sign=ce6f29de&sv=1)
The CoherenceSyncConfig
object allows us to do the following:
Hard reference the prefab in Editor, this means that whenever we have to do postprocessing in synced prefabs, we don't have to do a lookup or load them from Resources.
Serialize the method of loading and instantiating this prefab in runtime.
Soft reference the prefab in Runtime with a GUID, this means we can access the loading and instantiating implementations without having to load the prefab itself into memory.
📁 Assets/coherence/CoherenceSyncConfigs
is the default location of all CoherenceSyncConfig
objects.
The CoherenceSyncConfigRegistry
Every time a CoherenceSyncConfig
object is created, it gets added to a registry that is another ScriptableObject of type CoherenceSyncConfigRegistry
.
You can inspect all of the CoherenceSyncConfig
assets in one place in the CoherenceSync Objects window, found under the coherence > CoherenceSync Objects menu item:
This is a great way to see the configuration of different entities next to each other, and to do mass edits.
You can also manually inspect the CoherenceSyncConfigRegistry
by selecting it from 📁 Assets/coherence
folder
Last updated