Ejemplo n.º 1
0
        public StaticMemoryPoolBaseBase(Action <TValue> onDespawnedMethod)
        {
            _onDespawnedMethod = onDespawnedMethod;

#if UNITY_EDITOR
            StaticMemoryPoolRegistry.Add(this);
#endif
        }
Ejemplo n.º 2
0
        void Construct(
            IFactory <TContract> factory,
            DiContainer container,
            [InjectOptional]
            MemoryPoolSettings settings)
        {
            _settings  = settings ?? MemoryPoolSettings.Default;
            _factory   = factory;
            _container = container;

            _inactiveItems = new Stack <TContract>(_settings.InitialSize);

            if (!container.IsValidating)
            {
                for (int i = 0; i < _settings.InitialSize; i++)
                {
                    _inactiveItems.Push(AllocNew());
                }
            }

#if UNITY_EDITOR
            StaticMemoryPoolRegistry.Add(this);
#endif
        }
Ejemplo n.º 3
0
        public void Dispose()
        {
#if UNITY_EDITOR
            StaticMemoryPoolRegistry.Remove(this);
#endif
        }