Пример #1
0
        private void Despawn(SgtDebris debris)
        {
            debris.InvokeOnDespawn();

            if (debris.Pool == true)
            {
                SgtComponentPool <SgtDebris> .Add(debris);
            }
            else
            {
                SgtHelper.Destroy(debris.gameObject);
            }
        }
        private void Despawn(SgtDebris debris, int index)
        {
            debris.InvokeOnDespawn();

            if (debris.Pool == true)
            {
                SgtComponentPool <SgtDebris> .Add(debris);
            }
            else
            {
                SgtHelper.Destroy(debris.gameObject);
            }

            this.debris.RemoveAt(index);
        }
Пример #3
0
        private SgtDebris Spawn(SgtDebris prefab)
        {
            if (prefab.Pool == true)
            {
                targetPrefab = prefab;

                var debris = SgtComponentPool <SgtDebris> .Pop(DebrisMatch);

                if (debris != null)
                {
                    debris.transform.SetParent(null, false);

                    return(debris);
                }
            }

            return(Instantiate(prefab));
        }
        private SgtDebris Spawn(SgtDebris prefab)
        {
            if (prefab.Pool == true)
            {
                targetPrefab = prefab;

                var debris = SgtComponentPool <SgtDebris> .Pop(DebrisMatch);

                if (debris != null)
                {
                    debris.transform.SetParent(null, false);

                    return(debris);
                }
            }

            var clone = Instantiate(prefab);

            clone.gameObject.SetActive(true);

            return(clone);
        }
Пример #5
0
 private bool DebrisMatch(SgtDebris debris)
 {
     return(debris != null && debris.Prefab == targetPrefab);
 }
Пример #6
0
        private void Despawn(SgtDebris debris, int index)
        {
            Despawn(debris);

            spawnedDebris.RemoveAt(index);
        }