// MIT License - Copyright (c) 2025 wallstop // Full license text: https://github.com/wallstop/unity-helpers/blob/main/LICENSE namespace Samples.UnityHelpers.DI.Zenject { using global::Zenject; using UnityEngine; using WallstopStudios.UnityHelpers.Integrations.Zenject; /// /// Example Zenject memory pool that automatically hydrates relational fields when items are spawned. /// Bind this pool in an installer with /// /// Container.BindMemoryPool<RelationalConsumer, RelationalConsumerPool>() /// .FromComponentInNewPrefab(componentPrefab) /// .UnderTransform(poolRoot); /// /// public sealed class RelationalConsumerPool : RelationalMemoryPool { protected override void OnSpawned(RelationalConsumer item) { base.OnSpawned(item); if (item != null) { item.gameObject.SetActive(true); } } protected override void OnDespawned(RelationalConsumer item) { if (item != null) { item.gameObject.SetActive(false); } base.OnDespawned(item); } } }