Пример #1
0
    public virtual void DestroyObject(bool now = false, float time = 0.0f)
    {
        if (time > 0.0f)
        {
            StartCoroutine(__destroyAfter(time));

            return;
        }

        if (transform.parent != null)
        {
            if (transform.parent.tag == "PoolingContainer")
            {
                _destroy();
                return;
            }
        }

        if (now)
        {
            _destroy();
            return;
        }

        Util_PoolManagerDatabase.GetInstance(0).AddObjectToDestroy(this);

        _destroystate = DestroyState.kPrepareDestroy;
    }
Пример #2
0
    private IEnumerator __destroyAfter(float t)
    {
        yield return(new WaitForSeconds(t));

        Util_PoolManagerDatabase.GetInstance(0).AddObjectToDestroy(this);

        _destroystate = DestroyState.kPrepareDestroy;
    }
Пример #3
0
    IEnumerator __awake()
    {
        int index = 0;
        int count = _poolingDataBase.Length;

        if (count < _poolingDefinitions.Length)
        {
            _poolingDataBase = new Util_PoolManager[_poolingDefinitions.Length];

            while (count < _poolingDefinitions.Length)
            {
                Util_PoolManager o = new Util_PoolManager();

                o._noPooling = _noPooling;

                PoolingDefinition p = _poolingDefinitions[count++];

                if (p._amount == 0 && !_noPooling)
                {
                    Debug.LogWarning("Create a pooling with 0 element!");

                    continue;
                }

                o.Create(p, gameObject);

                yield return(o.waitingForCompletition());

                _poolingDataBase[index++] = o;
            }
        }

        yield return(new WaitForEndOfFrame());

        _loaded = true;

        __ENEMY   = Util_PoolManagerDatabase.GetInstance("ENEMY");
        __FX      = Util_PoolManagerDatabase.GetInstance("FX");
        __BULLETS = Util_PoolManagerDatabase.GetInstance("BULLETS");

                #if UNITY_EDITOR
        string children = "";

        for (int i = 0; i < transform.childCount; ++i)
        {
            children += transform.GetChild(i).name;
            children += "\n";
        }

        Debug.Log(transform.name);
        Debug.Log(children);
                #endif
    }