Ejemplo n.º 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();
            }
        }
Ejemplo n.º 2
0
        DisplayObject HitTest_Container()
        {
            Vector2 localPoint = WorldToLocal(HitTestContext.worldPoint, HitTestContext.direction);

            if (_vertexMatrix != null)
            {
                HitTestContext.worldPoint = this.cachedTransform.TransformPoint(new Vector2(localPoint.x, -localPoint.y));
            }

            if (hitArea != null)
            {
                if (!hitArea.HitTest(_contentRect, localPoint))
                {
                    return(null);
                }

                if (hitArea is MeshColliderHitTest)
                {
                    localPoint = ((MeshColliderHitTest)hitArea).lastHit;
                }
            }
            else
            {
                if (_clipRect != null && !((Rect)_clipRect).Contains(localPoint))
                {
                    return(null);
                }
            }

            if (_mask != null)
            {
                DisplayObject tmp = _mask.InternalHitTestMask();
                if (!reversedMask && tmp == null || reversedMask && tmp != null)
                {
                    return(null);
                }
            }

            DisplayObject target = null;

            if (touchChildren)
            {
                int count = _children.Count;
                for (int i = count - 1; i >= 0; --i) // front to back!
                {
                    DisplayObject child = _children[i];
                    if ((child._flags & Flags.GameObjectDisposed) != 0)
                    {
                        child.DisplayDisposedWarning();
                        continue;
                    }

                    if (child == _mask || (child._flags & Flags.TouchDisabled) != 0)
                    {
                        continue;
                    }

                    target = child.InternalHitTest();
                    if (target != null)
                    {
                        break;
                    }
                }
            }

            if (target == null && opaque && (hitArea != null || _contentRect.Contains(localPoint)))
            {
                target = this;
            }

            return(target);
        }