This repository was archived by the owner on Aug 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
ObjectPooler.cs
Erik edited this page Apr 25, 2019
·
4 revisions
Script: ObjectPooler.cs
- GetPooledObject(GameObject go) - Pops a PoolableObject from the Queue or instantiates a new one. Should be used in placed of "Instantiate". The parameter go should be a prefab.
- ReleasePooledObject(PoolableObject po) - Adds the PoolableObject back to the queue.
- None
- prePooledObjects - List of objects and their count that are instantiated and added to the pool on load.
The ObjectPooler maintains a dictionary of queues for each unique prefab. When a prefab instantiation is requested via GetPooledObject(go), the dictionary is first checked for that queue. If the queue exists and at least one object is in the queue, it is popped and returned. Otherwise, a new object is instantiated. The PoolableObject component is added to all objects instantiated via the ObjectPooler. When a PoolableObject is disabled, it is added back to the queue for reuse.
Script Documentation
General Scripts
Generic Character Scripts
Enemy Scripts
Player Scripts
Erik's ongoing laundry list of TODOs that he doesn't want to create issues for