예제 #1
0
    static private void _DetachChildrenAndDestroy(Transform transform)
    {
        int childCount = transform.childCount;

        Transform[] children = new Transform[childCount];

        var myTransform = transform; // cache for performance reasons

        int i;

        for (i = 0; i < childCount; i++)
        {
            children[i] = myTransform.GetChild(i);
        }
        myTransform.DetachChildren();

        for (i = 0; i < childCount; i++)
        {
            GameObject obj = children[i].gameObject;
            if (obj)
            {
                ObjectPoolController.Destroy(obj);
            }
        }
    }
예제 #2
0
    private void _DestroyAudioObject()
    {
        //Debug.Log( "Destroy:" + audio.clip.name );
#if AUDIO_TOOLKIT_DEMO
        GameObject.Destroy(gameObject);
#else
        ObjectPoolController.Destroy(gameObject);
#endif
        _destroyIfNotPlaying = false;
    }
예제 #3
0
    static private void _DetachChildrenAndDestroy(Transform transform, bool destroyImmediate)
    {
        var po = transform.GetComponent <PoolableObject>();

        if (transform.childCount > 0)
        {
            List <PoolableObject> poolableChilds = new List <PoolableObject>();
            transform.GetComponentsInChildren <PoolableObject>(true, poolableChilds);

            if (po != null)
            {
                poolableChilds.Remove(po);
            }

            //first destroy all poolable childs.
            for (int i = 0; i < poolableChilds.Count; i++)
            {
                if (poolableChilds[i] == null || poolableChilds[i]._isInPool)
                {
                    continue;                                                                 //can happen when a poolable is a child of another poolable
                }
                if (destroyImmediate)
                {
                    ObjectPoolController.DestroyImmediate(poolableChilds[i].gameObject);
                }
                else
                {
                    ObjectPoolController.Destroy(poolableChilds[i].gameObject);
                }
            }
        }

        if (po != null)
        {
            //move poolable Object to pool
            po._PutIntoPool();
        }
        else
        {
            //destroy non-poolable object itself
            if (destroyImmediate)
            {
                GameObject.DestroyImmediate(transform.gameObject);
            }
            else
            {
                GameObject.Destroy(transform.gameObject);
            }
        }
    }
예제 #4
0
    /// <summary>
    /// Destroys the audio object (using <see cref="ObjectPoolController"/> if pooling is enabled)
    /// </summary>
    public void DestroyAudioObject()
    {
        if (audio.isPlaying)
        {
            _Stop();
        }

        //Debug.Log( "Destroy:" + audio.clip.name );
#if AUDIO_TOOLKIT_DEMO
        GameObject.Destroy(gameObject);
#else
        ObjectPoolController.Destroy(gameObject);
#endif
        _destroyIfNotPlaying = false;
    }
예제 #5
0
    /// <summary>
    /// Destroys the audio object (using <see cref="ObjectPoolController"/> if pooling is enabled)
    /// </summary>
    public void DestroyAudioObject()
    {
        if (IsPlaying())
        {
            _Stop();
        }

#if OUYA_PAUSE_SYSTEM
        OuyaSDK.unregisterPauseListener(this);
        OuyaSDK.unregisterResumeListener(this);
#endif

        //Debug.Log( "Destroy:" + _audioSource.clip.name );
#if AUDIO_TOOLKIT_DEMO
        GameObject.Destroy(gameObject);
#else
        ObjectPoolController.Destroy(gameObject);
#endif
        _IsInactive = true;
    }
예제 #6
0
    static private void _DetachChildrenAndDestroy(Transform transform)
    {
        int childCount = transform.childCount;

        Transform[] children = new Transform[childCount];

        int i;

        for (i = 0; i < childCount; i++)
        {
            children[i] = transform.GetChild(i);
        }
        transform.DetachChildren();

        for (i = 0; i < childCount; i++)
        {
            GameObject obj = children[i].gameObject;
            if (obj)
            {
                ObjectPoolController.Destroy(obj);
            }
        }
    }
예제 #7
0
 internal virtual void DestroyAudioObject()
 {
     StopAllCoroutines();
     ObjectPoolController.Destroy(gameObject);
 }