Skip to content
This repository has been archived by the owner on Mar 2, 2022. It is now read-only.
/ PoolManager Public archive

[LEGACY] Object pooling system for Unity.

Notifications You must be signed in to change notification settings

mackysoft/PoolManager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This library is a legacy. A more advanced object pooling system is available here.

XPool: https://github.com/mackysoft/XPool

PoolManager for Unity

PoolManager implements an object pool in Unity.

Inspector_NotPlaying

Environment

Unity 2018.1.0f2

Scripting (July, 2017)

First, add "MackySoft.Pooling" to using area.

using MackySoft.Pooling;

Get Pool

You can obtain the pool in either of the following ways.
"GetPoolSafe" automatically add a pool if there is no pool.
(PoolManager.Instance [prefab] and PoolManager.GetPool (prefab) are the same.)

Pool pool = PoolManager.Insance[prefab];

Pool pool = PoolManager.GetPool(prefab);

Pool pool = PoolManager.GetPoolSafe(prefab);

Or you can use it by caching in the following way.

Pool pool = PoolManager.AddPool(prefab);

Get Instance

Instances can be obtained from the pool in the following way.

GameObject ins = pool.Get(parent);

GameObject ins = pool.Get(position,rotation,parent);

var ins = pool.Get<COMPONENT_NAME>(parent);

var ins = pool.Get<COMPONENT_NAME>(position,rotation,parent);

Disable Object

This PoolManager recognizes inactive objects as being unused.

Destroy(pooledObject);//NO NO NO

pooledGameObject.SetActive(false);//OK with this!

Inspector

During playback, the number of pooled objects is displayed.
Also, you can not change prefabs and add pools from inspector.

Inspector_Playing

Links

Credits

About

[LEGACY] Object pooling system for Unity.

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Languages