Photon Quantum 3.0.0

Public Member Functions | Properties | List of all members
Quantum.QuantumEntityViewPool Class Reference

An implementation of a EntityView pool to be used with the QuantumEntityViewUpdater.Pool. Add this behaviour to the same game object that the QuantumEntityViewUpdater behaviour is on. Using QuantumCallback.Subscribe() with pooled objects as listener needs to use the onlyIfActiveAndEnabled option to not be callbacks from disabled pooled objects. More...

Inheritance diagram for Quantum.QuantumEntityViewPool:
Quantum.QuantumMonoBehaviour Quantum.IQuantumEntityViewPool

Public Member Functions

void Awake ()
 Create pre cached pooled game objects during Awake(). More...
 
virtual GameObject Create (GameObject prefab, bool activate=true, bool createIfEmpty=true)
 Create a pooled game object. More...
 
virtual GameObject Create (GameObject prefab, Transform parent, bool activate=true, bool createIfEmpty=true)
 Create a pooled game object. More...
 
virtual T Create< T > (T prefab, bool activate=true, bool createIfEmpty=true)
 Create a pooled game object and return the component of chose type. More...
 
virtual T Create< T > (T prefab, Transform parent, bool activate=true, bool createIfEmpty=true)
 Create a pooled game object and return the component of chose type. More...
 
virtual void Destroy (Component component, bool deactivate=true)
 Destroy or return the pooled game object that the component is attached to. More...
 
virtual void Destroy (GameObject instance, bool deactivate=true)
 Destroy or return the pooled game object. More...
 
virtual void Destroy (GameObject instance, float delay)
 Destroy or return the pooled game object after a delay. More...
 
void OnDestroy ()
 Shutdown the pool. More...
 
virtual void Prepare (GameObject prefab, int desiredCount)
 Create prefab instances and fill the pool. More...
 
void Update ()
 Update is used to track deferred pooled game object destroy requests. More...
 

Properties

int BorrowedCount [get]
 Returns how many pooled items are currently in use. More...
 
int PooledCount [get]
 Returns how many items are inside the pool in total. More...
 
- Properties inherited from Quantum.IQuantumEntityViewPool
int BorrowedCount [get]
 Returns how many pooled items are currently in use. More...
 
int PooledCount [get]
 Returns how many items are inside the pool in total. More...
 

Detailed Description

An implementation of a EntityView pool to be used with the QuantumEntityViewUpdater.Pool. Add this behaviour to the same game object that the QuantumEntityViewUpdater behaviour is on. Using QuantumCallback.Subscribe() with pooled objects as listener needs to use the onlyIfActiveAndEnabled option to not be callbacks from disabled pooled objects.

Member Function Documentation

◆ Create< T >() [1/2]

virtual T Quantum.QuantumEntityViewPool.Create< T > ( prefab,
bool  activate = true,
bool  createIfEmpty = true 
)
inlinevirtual

Create a pooled game object and return the component of chose type.

Template Parameters
TComponent type
Parameters
prefabPrefab to instantiate
activateCall SetActive() on the game object
createIfEmptyCreate a new entity if there is no suitable one found in the pool
Returns
Component on the created prefab instance, can be null

Implements Quantum.IQuantumEntityViewPool.

Type Constraints
T :Component 

◆ Create() [1/2]

virtual GameObject Quantum.QuantumEntityViewPool.Create ( GameObject  prefab,
bool  activate = true,
bool  createIfEmpty = true 
)
inlinevirtual

Create a pooled game object.

Parameters
prefabPrefab to instantiate
activateCall SetActive() on the game object
createIfEmptyCreate a new entity if there is no suitable one found in the pool
Returns
An instance of the prefab

Implements Quantum.IQuantumEntityViewPool.

◆ Create< T >() [2/2]

virtual T Quantum.QuantumEntityViewPool.Create< T > ( prefab,
Transform  parent,
bool  activate = true,
bool  createIfEmpty = true 
)
inlinevirtual

Create a pooled game object and return the component of chose type.

Template Parameters
TComponent type
Parameters
prefabPrefab to instantiate
parentCalls SetParent(parent) on the new game object transform when set
activateCall SetActive() on the game object
createIfEmptyCreate a new entity if there is no suitable one found in the pool
Returns
Component on the created prefab instance, can be null

Implements Quantum.IQuantumEntityViewPool.

Type Constraints
T :Component 

◆ Create() [2/2]

virtual GameObject Quantum.QuantumEntityViewPool.Create ( GameObject  prefab,
Transform  parent,
bool  activate = true,
bool  createIfEmpty = true 
)
inlinevirtual

Create a pooled game object.

Parameters
prefabPrefab to instantiate
parentCalls SetParent(parent) on the new game object transform when set
activateCall SetActive() on the game object
createIfEmptyCreate a new entity if there is no suitable one found in the pool
Returns
An instance of the prefab

Implements Quantum.IQuantumEntityViewPool.

◆ Destroy() [1/3]

virtual void Quantum.QuantumEntityViewPool.Destroy ( Component  component,
bool  deactivate = true 
)
inlinevirtual

Destroy or return the pooled game object that the component is attached to.

Parameters
componentComponent that belongs to the pooled game object.
deactivateCall SetActive(false) on the pooled game object before returning it to the pool

Implements Quantum.IQuantumEntityViewPool.

◆ Destroy() [2/3]

virtual void Quantum.QuantumEntityViewPool.Destroy ( GameObject  instance,
bool  deactivate = true 
)
inlinevirtual

Destroy or return the pooled game object.

Parameters
instancePoole game object
deactivateCall SetActive(false) on the pooled game object before returning it to the pool

Implements Quantum.IQuantumEntityViewPool.

◆ Destroy() [3/3]

virtual void Quantum.QuantumEntityViewPool.Destroy ( GameObject  instance,
float  delay 
)
inlinevirtual

Destroy or return the pooled game object after a delay.

Parameters
instancePoole game object
delayDelay in seconds to complete returning it to the pool

Implements Quantum.IQuantumEntityViewPool.

◆ Prepare()

virtual void Quantum.QuantumEntityViewPool.Prepare ( GameObject  prefab,
int  desiredCount 
)
inlinevirtual

Create prefab instances and fill the pool.

Parameters
prefabPrefab to created pooled instances
desiredCountThe number of instances to create and add to the pool

Implements Quantum.IQuantumEntityViewPool.

◆ Awake()

void Quantum.QuantumEntityViewPool.Awake ( )
inline

Create pre cached pooled game objects during Awake().

◆ OnDestroy()

void Quantum.QuantumEntityViewPool.OnDestroy ( )
inline

Shutdown the pool.

◆ Update()

void Quantum.QuantumEntityViewPool.Update ( )
inline

Update is used to track deferred pooled game object destroy requests.

Property Documentation

◆ PooledCount

int Quantum.QuantumEntityViewPool.PooledCount
get

Returns how many items are inside the pool in total.

◆ BorrowedCount

int Quantum.QuantumEntityViewPool.BorrowedCount
get

Returns how many pooled items are currently in use.