Skip to content
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.

ComponentPool

pointcache edited this page Jan 17, 2017 · 2 revisions

ComponentPool is a pretty complex class implementing generic static Pool

Once a Component is spawned into the scene it registers itself in the pool, which is automatically created for new types of components.

You can access first component in the pool, use this for "singleton" components:

var cfg = Pool<GraphicsConfig>.First;

You can get the list of all currently existing in the scene components:

foreach (Bird bird in Pool<Bird>.components)
{
    Fly();
}

You can subscribe to get notified when components are added or removed to the pool:

   Pool<Star>.OnAdded += () => PlaySound();

There are other things you can use

Pool<T>.Empty //is the pool empty
Pool<T>.Count //how many components 

There are other internal members you probably won't need.

Clone this wiki locally