public PoolSettings(PoolSettings src) { Prewarm = src.Prewarm; AutoCreate = src.AutoCreate; MinItems = src.MinItems; Threshold = src.Threshold; Speed = src.Speed; Debug = src.Debug; }
public Pool(PoolSettings settings = null) { Settings = settings ?? new PoolSettings(); Identifier = typeof(T).FullName; mLastTime = DTTime.TimeSinceStartup + UnityEngine.Random.Range(0, Settings.Speed); if (Settings.Prewarm) { Reset(); } }
public void Initialize(System.Type type, PoolSettings settings) { m_Identifier = type.AssemblyQualifiedName; m_Settings = settings; mLastTime = DTTime.TimeSinceStartup + UnityEngine.Random.Range(0, Settings.Speed); if (Settings.Prewarm) { Reset(); } }
public void Initialize(string ident, PoolSettings settings, params GameObject[] prefabs) { Identifier = ident; m_Settings = settings; Prefabs = new List <GameObject>(prefabs); mLastTime = DTTime.TimeSinceStartup + UnityEngine.Random.Range(0, Settings.Speed); if (Settings.Prewarm) { Reset(); } }
public Pool <T> CreateTypePool <T>(PoolSettings settings = null) { PoolSettings s = settings ?? new PoolSettings(DefaultSettings); IPool res = null; if (!TypePools.TryGetValue(typeof(T), out res)) { res = new Pool <T>(s); TypePools.Add(typeof(T), res); } return((Pool <T>)res); }
public ComponentPool CreateComponentPool <T>(PoolSettings settings = null) where T : Component { if (!IsInitialized) { Initialize(); } PoolSettings s = settings ?? new PoolSettings(DefaultSettings); IPool res = null; if (!Pools.TryGetValue(typeof(T).AssemblyQualifiedName, out res)) { res = gameObject.AddComponent <ComponentPool>(); ((ComponentPool)res).Initialize(typeof(T), s); Pools.Add(res.Identifier, res); } return((ComponentPool)res); }
public PrefabPool CreatePrefabPool(string name, PoolSettings settings = null, params GameObject[] prefabs) { if (!IsInitialized) { Initialize(); } PoolSettings s = settings ?? new PoolSettings(DefaultSettings); IPool pool = null; if (!Pools.TryGetValue(name, out pool)) { PrefabPool p = gameObject.AddComponent <PrefabPool>(); p.Initialize(name, s, prefabs); Pools.Add(name, p); return(p); } return((PrefabPool)pool); }