Exemplo n.º 1
0
            private void RemoveInternal(UpdateDelegate update)
            {
                if (update == null)
                {
                    return;
                }
                int        key = update.GetHashCode();
                UpdateItem updater;
                int        removeAt = -1;

                if (mUpdating)
                {
                    if (mUpdaters.TryGetValue(key, out updater))
                    {
                        mUpdaters.Remove(key);
                        removeAt = updater.index;
                        if (mInterior >= updater.index)
                        {
                            mInterior--;
                        }
                    }
                    else if (mNewUpdaters.RemoveFromQueue(key))
                    {
                        removeAt = mInterior + mNewCount;
                        mNewCount--;
                        if (mNewCount > 0)
                        {
                            mNewPriority = mNewUpdaters.Peek().priority;
                        }
                    }
                }
                else
                {
                    if (mUpdaters.TryGetValue(key, out updater))
                    {
                        mUpdaters.Remove(key);
                        removeAt = updater.index;
                    }
                    else
                    {
                        UpdateItem u;
                        int        p;
                        if (mNewUpdaters.RemoveFromQueue(key, out u, out p))
                        {
                            UpdateItem.Cache(u);
                        }
                    }
                }
                if (removeAt >= 0)
                {
                    UpdateItem.Cache(mSortedUpdaters[removeAt]);
                    mSortedUpdaters.RemoveAt(removeAt);
                    for (int i = mSortedUpdaters.Count - 1; i >= removeAt; i--)
                    {
                        UpdateItem u = mSortedUpdaters[i];
                        u.index = i;
                    }
                }
            }
Exemplo n.º 2
0
            private void AddInternal(UpdateDelegate update, bool ignoreBehaviour, int priority, bool unscaled)
            {
                if (update == null)
                {
                    return;
                }
                int key = update.GetHashCode();

                if (mUpdaters.ContainsKey(key) || mNewUpdaters.Contains(key))
                {
                    return;
                }
                MonoBehaviour behaviour = ignoreBehaviour ? null : update.Target as MonoBehaviour;
                UpdateItem    updater   = UpdateItem.Get(key, priority, unscaled, behaviour, update);

                if (mUpdating)
                {
                    mToAddUpdaters.Add(updater);
                }
                else
                {
                    mNewUpdaters.Enqueue(key, updater, priority);
                }
            }