Instead of hard referencing Prefabs in your scripts to instantiate them using Unity's own Instantiate()
, you can reference a CoherenceSyncConfig
and instantiate your local Prefab instances through our API.
This will utilize the internal INetworkObjectProvider
and INetworkObjectInstantiator
interfaces to load and instantiate the Prefab in a given networked scene (a scene with a CoherenceBridge component in it).
For instance:
You can also hard reference the Prefab in your script, and use our extensions to instantiate the Prefab easily using the internal INetworkObjectInstantiator
interface implementation.
The main difference is that the previous approach doesn't need a Prefab hard reference, and you won't have to change the code if the way that the Prefab is loaded into memory changes (for example, if you go from Resources to load it via Addressables).