Instantiating from CoherenceSyncConfig
Reference to the CoherenceSyncConfig
using Coherence.Toolkit;
using UnityEngine;
public class CoherenceSyncConfigExample : MonoBehaviour
{
public CoherenceSyncConfig prefabSyncConfig;
public CoherenceBridge bridge;
private CoherenceSync instance1;
private CoherenceSync instance2;
void Start()
{
// Load the prefab and instantiate it in the current scene
instance1 = prefabSyncConfig.GetInstance();
// Load the prefab and instantiate it in the specific networked scene for the given CoherenceBridge
instance2 = prefabSyncConfig.GetInstance(bridge, Vector3.zero, Quaternion.identity);
}
private void OnDestroy()
{
// Instances have to be destroyed via the ReleaseInstance method, so that its destruction is handle by the
// internal INetworkObjectInstantiator
prefabSyncConfig.ReleaseInstance(instance1);
prefabSyncConfig.ReleaseInstance(instance2);
}
}Reference to a Prefab ("hard reference")
Was this helpful?

