public sealed override BaseCharacter AllocObject() { IObjectPoolCallback allocatedObj = AllocObjectInternal(); Assert.IsNotNull(allocatedObj); allocatedObj.OnAllocated(); return((BaseCharacter)allocatedObj); }
public sealed override Food AllocObject() { IObjectPoolCallback allocatedObj = AllocObjectInternal(); Assert.IsNotNull(allocatedObj); allocatedObj.OnAllocated(); return((Food)allocatedObj); }
public virtual T AllocObject() { IObjectPoolCallback allocatedObj = AllocObjectInternal(); if (allocatedObj == null) { allocatedObj = new T(); } allocatedObj.OnAllocated(); return((T)allocatedObj); }
public ObjectPoolImpl(int id, PoolManagedBehaviour prefab, ObjectPoolConfig config, Transform hierarchyParent = null, IObjectPoolCallback <PoolManagedBehaviour> callback = null) { this.id = id; this.prefab = prefab; this.Config = config; this.hierarchyParent = hierarchyParent; this.callback = callback ?? new NopObjectPoolCallBack <PoolManagedBehaviour>(); hasParent = hierarchyParent != null; prefab.gameObject.SetActive(false); // avoid to call OnAwake OnEnable and OnDisable when CreateInstance if (hierarchyParent != null) { UnityEngine.Object.DontDestroyOnLoad(hierarchyParent); } }