Defines all the methods that a Object Pool must implement, so that PUN can use it. More...
|GameObject||Instantiate (string prefabId, Vector3 position, Quaternion rotation)|
|This is called when PUN wants to create a new instance of an entity prefab. Must return valid GameObject with PhotonView. More...|
|void||Destroy (GameObject gameObject)|
|This is called when PUN wants to destroy the instance of an entity prefab. More...|
Defines all the methods that a Object Pool must implement, so that PUN can use it.
To use a Object Pool for instantiation, you can set PhotonNetwork.ObjectPool. That is used for all objects, as long as ObjectPool is not null. The pool has to return a valid non-null GameObject when PUN calls Instantiate. Also, the position and rotation must be applied.
Please note that pooled GameObjects don't get the usual Awake and Start calls. OnEnable will be called (by your pool) but the networking values are not updated yet when that happens. OnEnable will have outdated values for PhotonView (isMine, etc.). You might have to adjust scripts.
PUN will call OnPhotonInstantiate (see IPunCallbacks). This should be used to setup the re-used object with regards to networking values / ownership.
This is called when PUN wants to destroy the instance of an entity prefab.
A pool needs some way to find out which type of GameObject got returned via Destroy(). It could be a tag or name or anything similar.
|gameObject||The instance to destroy.|
This is called when PUN wants to create a new instance of an entity prefab. Must return valid GameObject with PhotonView.
|prefabId||The id of this prefab.|
|position||The position we want the instance instantiated at.|
|rotation||The rotation we want the instance to take.|