C# Class GenericPooling, unity-pooling

A generic pooling script to control gameobject's activations and to avoid instantiate and destroy gameobjects many times.
Inheritance: BaseScript
Exibir arquivo Open project: joaokucera/unity-pooling Class Usage Examples

Public Properties

Property Type Description
initialPoolSize int
isPoolExpandable bool
prefab GameObject

Protected Properties

Property Type Description
pool List

Public Methods

Method Description
GetObjectFromPool ( Vector2 position, bool active = true ) : GameObject

Get first game object available inside of pool.

Start ( ) : void

Use this for initialization.

Protected Methods

Method Description
Initialize ( ) : void

Initialize pool.

Private Methods

Method Description
CreateNewObject ( ) : GameObject

Create new game object.

PrepareObjectToResponse ( GameObject obj, Vector2 position, bool active ) : GameObject

Prepare game object to response.

Method Details

GetObjectFromPool() public method

Get first game object available inside of pool.
public GetObjectFromPool ( Vector2 position, bool active = true ) : GameObject
position Vector2 Position to be displayed.
active bool To activate or not.
return GameObject

Initialize() protected method

Initialize pool.
protected Initialize ( ) : void
return void

Start() public method

Use this for initialization.
public Start ( ) : void
return void

Property Details

initialPoolSize public_oe property

The initial pool size.
public int initialPoolSize
return int

isPoolExpandable public_oe property

Define if pool is expadable.
public bool isPoolExpandable
return bool

pool protected_oe property

A pool of game objects.
protected List pool
return List

prefab public_oe property

Prefab for pool.
public GameObject prefab
return GameObject