Ejemplo n.º 1
0
    public sealed override BaseCharacter AllocObject()
    {
        IObjectPoolCallback allocatedObj = AllocObjectInternal();

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

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

        if (allocatedObj == null)
        {
            allocatedObj = new T();
        }
        allocatedObj.OnAllocated();
        return((T)allocatedObj);
    }
Ejemplo n.º 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);
            }
        }