Photon Unity Networking 2: DefaultPool Class Reference

Photon Unity Networking 2

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
gameObjectThe 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
prefabIdString identifier for the networked object.
positionLocation of the new object.
rotationRotation 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.

Online Documentation  -  Dashboard  -  Support Forum Exit Games GmbH