Exemple #1
0
        public void PerformClipping()
        {
            if (m_ShouldRecalculateClipRects)
            {
                MaskUtilities.GetRectMaskForClip(this, m_Clippers);
                m_ShouldRecalculateClipRects = false;
            }

            bool validRect       = true;
            Rect clipRect        = Clipping.FindCullAndClipWorldRect(m_Clippers, out validRect);
            bool clipRectChanged = clipRect != m_LastClipRectCanvasSpace;

            if (clipRectChanged || m_ForceClip)
            {
                foreach (var clipTarget in m_ClipTargets)
                {
                    clipTarget.SetClipRect(clipRect, validRect);
                }

                m_LastClipRectCanvasSpace = clipRect;
                m_LastValidClipRect       = validRect;
            }

            foreach (var clipTarget in m_ClipTargets)
            {
                var maskable = clipTarget as MaskableGraphic;
                if (maskable != null && !maskable.canvasRenderer.hasMoved && !clipRectChanged)
                {
                    continue;
                }
                clipTarget.Cull(m_LastClipRectCanvasSpace, m_LastValidClipRect);
            }
        }