Generic Unity pooling primitives for the Immersive Framework package set.
Use the package source already configured by the consuming project. Resolve the installed version from Packages/manifest.json and packages-lock.json; this README does not pin a version for discovery.
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.
The Pooling Usage Guide is the canonical authoring and runtime procedure. The Boundary defines ownership and package limits. Pooling How-To is retained for the package's manual QA context-menu procedure.
| Intent | Guide |
|---|---|
| Author a pool asset and choose registration behavior | Asset authoring, Registration Mode |
| Use a scene-local host | PoolRuntimeHost |
| Own a service explicitly | PoolService |
| Rent, return, auto-return, inspect or clean up instances | Return, Auto-return, Snapshots, Cleanup |
| Run the available manual smoke | Manual QA procedure |
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.PoolRuntimeSnapshot: active, inactive, and total counts exposed byIPoolService.TryGetSnapshot.
- 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.
The service instance owns its registered pools. Call Shutdown when the composition owner ends; after shutdown, service operations throw. PoolLifetimeScope only labels definitions for explicit ClearPoolsForScope calls. It does not automatically follow Route, Activity, scene, or Framework lifecycle.
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.
com.immersive.audio uses explicit PoolDefinitionAsset references and IPoolService composition for pooled SFX. Pooling does not implement Audio behavior, Audio fallback policy, voice budgeting, or Audio bootstrap.
The package provides a manually invoked QA context-menu driver, not an automated test suite. Follow the manual QA procedure. The procedure checks authoring and pool operations but is not evidence that automated tests ran.
Licensed under the MIT License.