Generic Unity pooling primitives for the Immersive Framework package set.
com.immersive.pooling owns reusable pooling mechanics only:
- pure contracts in
Immersive.Pooling.Runtime; - Unity
GameObjectpooling inImmersive.Pooling.Unity; - authoring data through
PoolDefinitionAsset; - explicit composition through
PoolServiceor optionalPoolRuntimeHost.
It does not own framework bootstrap, Audio, VFX, gameplay identity, scene flow, service location, or singleton registration.
IPoolable: minimal take/return callbacks.IPoolLifecycle: optional created/destroyed callbacks.PoolableBehaviour:MonoBehaviourbase implementing pool state and lifecycle callbacks.PoolDefinitionAsset: prefab, capacity, expansion, registration, lifetime, prewarm, and auto-return settings.GameObjectPool: local instantiable pool withRent,Spawn,Return,ReturnAll,Clear, active/inactive counts, max size, and expansion policy.IPoolService: explicit service contract overPoolDefinitionAsset.PoolService: non-singleton service that owns registered pools by asset reference.PoolRuntimeHost: optional scene component that composes aPoolServiceand declared pool definitions.PoolReturnHandle: component added to pooled instances so an object can return itself to its origin pool.
- Create
Assets > Create > Immersive > Pooling > Pool Definition. - Assign a prefab.
- Set
Initial Capacity,Max Size, andCan Expand. - Enable
Prewarm On RegisterwhenEnsureRegisteredshould create the initial instances. - Choose
LazyOnFirstRentif rent may auto-register the pool, orExplicitPrepareOnlyif a host/consumer must register it first. - Set
Auto Return Secondsonly for generic timed return behavior. Use0to disable.
var service = new PoolService();
service.EnsureRegistered(definition);
var instance = service.Rent(definition, parent);
service.Return(definition, instance);
service.ReturnAll(definition);
service.Clear(definition);
service.Shutdown();PoolDefinitionAsset is the identity. The package does not parse strings to resolve pools.
Add PoolRuntimeHost to a scene object, assign the pool definitions, and let it initialize on Awake or call Initialize manually. The host is optional composition; it is not a global singleton and does not depend on com.immersive.framework.
Instances rented from GameObjectPool receive a PoolReturnHandle. Code on the instance can call:
GetComponent<PoolReturnHandle>().ReturnToPool();Invalid or duplicate returns return false and do not corrupt pool state.
Audio can later hold explicit PoolDefinitionAsset references and receive an IPoolService from its own composition path. This package does not implement Audio behavior, Audio fallback policy, voice budgeting, or Audio bootstrap.
- Create a
PoolDefinitionAssetwith a simple prefab. - Add
PoolRuntimeHostand assign the definition. - Prewarm.
- Rent or spawn three objects.
- Return one object.
- Return all.
- Clear the pool.
- Confirm
PoolableBehaviourcallbacks and active/inactive counts.