Photon Unity Networking 2 2.30

Public Member Functions | Public Attributes | List of all members
DefaultPool Class Reference

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

◆ Destroy()

void Destroy ( GameObject  gameObject)

Simply destroys a GameObject.

Parameters
gameObjectThe GameObject to get rid of.

Implements IPunPrefabPool.

◆ Instantiate()

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

◆ ResourceCache

readonly Dictionary<string, GameObject> ResourceCache = new Dictionary<string, GameObject>()

Contains a GameObject per prefabId, to speed up instantiation.