Example #1
0
        private static void CoroutineRemoveAtSwap(Coroutine coroutine, bool returnToPool)
        {
            Coroutine endCoroutine = coroutines[coroutines.Count - 1];

            coroutines.RemoveAtSwapEx(ref coroutine.mainCollectionIndex, ref endCoroutine.mainCollectionIndex);

            if (returnToPool)
            {
                UObject owner;
                if (coroutine.objectsCollectionIndex >= 0 && ((owner = coroutine.Owner as UObject) != null))
                {
                    List <Coroutine> collection;
                    if (coroutinesByObject.TryGetValue(owner, out collection))
                    {
                        Coroutine end = collection[collection.Count - 1];
                        collection.RemoveAtSwapEx(ref coroutine.objectsCollectionIndex, ref end.objectsCollectionIndex);
                    }
                }

                if (coroutine.tagsCollectionIndex >= 0 && !string.IsNullOrEmpty(coroutine.Tag))
                {
                    List <Coroutine> collection;
                    if (coroutinesByTag.TryGetValue(coroutine.Tag, out collection))
                    {
                        Coroutine end = collection[collection.Count - 1];
                        collection.RemoveAtSwapEx(ref coroutine.tagsCollectionIndex, ref end.tagsCollectionIndex);
                    }
                }

                if (coroutine.IsPooled)
                {
                    CoroutinePool.ReturnObject(coroutine);
                }
            }
        }
Example #2
0
        private static void CoroutineRemoveAtSwap(Coroutine coroutine, bool returnToPool)
        {
            Coroutine endCoroutine = coroutines[coroutines.Count - 1];

            coroutines.RemoveAtSwapEx(ref coroutine.mainCollectionIndex, ref endCoroutine.mainCollectionIndex);
            if (returnToPool && coroutine.IsPooled)
            {
                CoroutinePool.ReturnObject(coroutine);
            }
        }