A delegate used by Realtime / Room to instantiate and destroy prefab instances. This can be used to implement object pooling for realtime prefab instances.



GameObject InstantiateRealtimePrefab(GameObject prefab)

Called by Room to instantiate an instance of the given prefab. The default implementation calls UnityEngine.Object.Instantiate(prefab).

The prefab instance.

  • prefab: The prefab that should be instantiated.

void DestroyRealtimePrefab(GameObject prefabInstance)

Called by Room to destroy a realtime prefab instance. The default implementation calls UnityEngine.Object.Destroy(prefabInstance).

When implementing object pooling, use this method to return the prefab to the pool.

  • prefabInstance: The prefab instance to destroy or return to the pool for reuse.