The Prefab pooling system

Hopefully, we now have an understanding of what we need from our pooling system, so all that's left is to implement it. The requirements are as follows:

  • It must accept requests to spawn a GameObject instance from a Prefab, an initial position, and an initial rotation:
    • If a despawned version already exists, it should respawn the first available one
    • If it does not exist, then it should instantiate a new GameObject instance from the Prefab
    • In either case, the Spawned() method should be invoked on all IPoolableComponent interface classes attached to GameObject
  • It must accept requests to despawn a specific GameObject instance:
    • If the object is managed by the pooling system, it should deactivate it and call the

Get Unity Game Optimization - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.