示例#1
0
        override public void Update(UpdateContext context)
        {
            if ((_flags & Flags.UserGameObject) != 0 && !gameObject.activeInHierarchy)
            {
                return;
            }

            base.Update(context);

            if (_paintingMode != 0)
            {
                if ((_flags & Flags.CacheAsBitmap) != 0 && _paintingInfo.flag == 2)
                {
                    if (onUpdate != null)
                    {
                        onUpdate();
                    }
                    return;
                }

                context.EnterPaintingMode();
            }

            if (_mask != null)
            {
                context.EnterClipping(this.id, reversedMask);
                if (_mask.graphics != null)
                {
                    _mask.graphics._PreUpdateMask(context, _mask.id);
                }
            }
            else if (_clipRect != null)
            {
                context.EnterClipping(this.id, this.TransformRect((Rect)_clipRect, null), clipSoftness);
            }

            float savedAlpha = context.alpha;

            context.alpha *= this.alpha;
            bool savedGrayed = context.grayed;

            context.grayed = context.grayed || this.grayed;

            if ((_flags & Flags.FairyBatching) != 0)
            {
                context.batchingDepth++;
            }

            if (context.batchingDepth > 0)
            {
                int cnt = _children.Count;
                for (int i = 0; i < cnt; i++)
                {
                    DisplayObject child = _children[i];
                    if ((child._flags & Flags.GameObjectDisposed) != 0)
                    {
                        child.DisplayDisposedWarning();
                        continue;
                    }

                    if (child.visible)
                    {
                        child.Update(context);
                    }
                }
            }
            else
            {
                if (_mask != null)
                {
                    _mask.renderingOrder = context.renderingOrder++;
                }

                int cnt = _children.Count;
                for (int i = 0; i < cnt; i++)
                {
                    DisplayObject child = _children[i];
                    if ((child._flags & Flags.GameObjectDisposed) != 0)
                    {
                        child.DisplayDisposedWarning();
                        continue;
                    }

                    if (child.visible)
                    {
                        if (!(child.graphics != null && child.graphics._maskFlag == 1)) //if not a mask
                        {
                            child.renderingOrder = context.renderingOrder++;
                        }

                        child.Update(context);
                    }
                }

                if (_mask != null)
                {
                    if (_mask.graphics != null)
                    {
                        _mask.graphics._SetStencilEraserOrder(context.renderingOrder++);
                    }
                }
            }

            if ((_flags & Flags.FairyBatching) != 0)
            {
                if (context.batchingDepth == 1)
                {
                    SetRenderingOrder(context);
                }
                context.batchingDepth--;
            }

            context.alpha  = savedAlpha;
            context.grayed = savedGrayed;

            if (_clipRect != null || _mask != null)
            {
                context.LeaveClipping();
            }

            if (_paintingMode != 0)
            {
                context.LeavePaintingMode();
                UpdateContext.OnEnd += _paintingInfo.captureDelegate;
            }

            if (onUpdate != null)
            {
                onUpdate();
            }
        }