Skip to content

mtaha3249/Generic-Pool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Generic-Pool


How to use it?

  • Add Pool Manager to GameObject.
  • The Editor will look like this.

Screenshot 2021-11-08 at 10 52 08 PM

  • Check or Uncheck Don't Destroy on Load.
  • Add Element to the list.
  • Give initial amount.
  • Use the following code to spawn. (Note: Prefab should be same in the prefabToSpawn as given in the Pool Manager)
GameObject spawned = PoolManager.Instance.Spawn(prefabToSpawn, Position, Rotation, Parent);
  • To Despawn use the following code.
PoolManager.Instance.Despawn(gameObjectToDeSpawn, cleanHierarchy);
  • I have Added delegates called on item Spawned and item Despawned.
void Start()
{
  PoolManager.Instance.OnSpawned += Func;
  PoolManager.Instance.OnDespawned += Func1;
}

void Func(GameObject itemSpawned)
{
  // do something
}

void Func1(GameObject itemDespawned)
{
  // do something
}

void Destroy()
{
  PoolManager.Instance.OnSpawned -= Func;
  PoolManager.Instance.OnDespawned -= Func1;
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages