UnityEngine.UI.Clipping.RectIntersect C# (CSharp) Method

RectIntersect() private static method

private static RectIntersect ( Rect a, Rect b ) : Rect
a UnityEngine.Rect
b UnityEngine.Rect
return UnityEngine.Rect
        private static Rect RectIntersect(Rect a, Rect b)
        {
            float x = Mathf.Max(a.x, b.x);
            float num2 = Mathf.Min((float) (a.x + a.width), (float) (b.x + b.width));
            float y = Mathf.Max(a.y, b.y);
            float num4 = Mathf.Min((float) (a.y + a.height), (float) (b.y + b.height));
            if ((num2 >= x) && (num4 >= y))
            {
                return new Rect(x, y, num2 - x, num4 - y);
            }
            return new Rect(0f, 0f, 0f, 0f);
        }
    }

Usage Example

Ejemplo n.º 1
0
        public static Rect FindCullAndClipWorldRect(List <RectMask2D> rectMaskParents, out bool validRect)
        {
            Rect result;

            if (rectMaskParents.Count == 0)
            {
                validRect = false;
                result    = default(Rect);
            }
            else
            {
                Rect a = rectMaskParents[0].canvasRect;
                for (int i = 0; i < rectMaskParents.Count; i++)
                {
                    a = Clipping.RectIntersect(a, rectMaskParents[i].canvasRect);
                }
                bool flag = a.width <= 0f || a.height <= 0f;
                if (flag)
                {
                    validRect = false;
                    result    = default(Rect);
                }
                else
                {
                    Vector3 vector  = new Vector3(a.x, a.y, 0f);
                    Vector3 vector2 = new Vector3(a.x + a.width, a.y + a.height, 0f);
                    validRect = true;
                    result    = new Rect(vector.x, vector.y, vector2.x - vector.x, vector2.y - vector.y);
                }
            }
            return(result);
        }
All Usage Examples Of UnityEngine.UI.Clipping::RectIntersect