Photon Unity Networking 2
2.12
|
The default implementation of a PrefabPool for PUN, which actually Instantiates and Destroys GameObjects but pools a resource. More...
Inherits IPunPrefabPool.
Public Member Functions | |
GameObject | Instantiate (string prefabId, Vector3 position, Quaternion rotation) |
Returns an inactive instance of a networked GameObject, to be used by PUN. More... | |
void | Destroy (GameObject gameObject) |
Simply destroys a GameObject. More... | |
Public Attributes | |
readonly Dictionary< string, GameObject > | ResourceCache = new Dictionary<string, GameObject>() |
Contains a GameObject per prefabId, to speed up instantiation. More... | |
Detailed Description
The default implementation of a PrefabPool for PUN, which actually Instantiates and Destroys GameObjects but pools a resource.
This pool is not actually storing GameObjects for later reuse. Instead, it's destroying used GameObjects. However, prefabs will be loaded from a Resources folder and cached, which speeds up Instantiation a bit.
The ResourceCache is public, so it can be filled without relying on the Resources folders.
Member Function Documentation
void Destroy | ( | GameObject | gameObject | ) |
Simply destroys a GameObject.
- Parameters
-
gameObject The GameObject to get rid of.
Implements IPunPrefabPool.
GameObject Instantiate | ( | string | prefabId, |
Vector3 | position, | ||
Quaternion | rotation | ||
) |
Returns an inactive instance of a networked GameObject, to be used by PUN.
- Parameters
-
prefabId String identifier for the networked object. position Location of the new object. rotation Rotation of the new object.
- Returns
Implements IPunPrefabPool.
Member Data Documentation
readonly Dictionary<string, GameObject> ResourceCache = new Dictionary<string, GameObject>() |
Contains a GameObject per prefabId, to speed up instantiation.