Beispiel #1
0
    public sealed override BaseCharacter AllocObject()
    {
        IObjectPoolCallback allocatedObj = AllocObjectInternal();

        Assert.IsNotNull(allocatedObj);
        allocatedObj.OnAllocated();
        return((BaseCharacter)allocatedObj);
    }
Beispiel #2
0
    public sealed override Food AllocObject()
    {
        IObjectPoolCallback allocatedObj = AllocObjectInternal();

        Assert.IsNotNull(allocatedObj);
        allocatedObj.OnAllocated();
        return((Food)allocatedObj);
    }
Beispiel #3
0
    public virtual T AllocObject()
    {
        IObjectPoolCallback allocatedObj = AllocObjectInternal();

        if (allocatedObj == null)
        {
            allocatedObj = new T();
        }
        allocatedObj.OnAllocated();
        return((T)allocatedObj);
    }
Beispiel #4
0
        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);
            }
        }