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 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 from the Prefab
    • In either case, the Spawned() method should be invoked on all IPoolableComponent Interface Classes attached to the GameObject
  • It must accept requests to despawn a specific GameObject:
    • If the object is managed by the Pooling System, it should deactivate it and call the Despawned() method on all ...

Get Unity 2017 Game Optimization - Second 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.