Пример #1
0
        static public void SplitByX(this Rect item, float x, out Rect left, out Rect right)
        {
            float split = x.Min(item.xMax);

            left  = RectExtensions.CreateStrictMinMaxRect(item.min, item.max.GetWithX(split));
            right = RectExtensions.CreateStrictMinMaxRect(item.min.GetWithX(split), item.max);
        }
Пример #2
0
 static public void DrawCenterRect(Vector2 center, Vector2 size)
 {
     GUI.DrawTexture(
         RectExtensions.CreateCenterRect(center, size),
         GetWhitePixelTexture()
         );
 }
Пример #3
0
        private void Start()
        {
            Rect inner_rect = RectExtensions.CreateCenterRect(offset, size);
            Rect outer_rect = inner_rect.GetEnlarged(thickness);

            outer_rect.GetSubtraction(inner_rect).Process(r => this.AddComponent <BoxCollider2D>().SetLocalRect(r));
        }
Пример #4
0
        static public void SplitByY(this Rect item, float y, out Rect bottom, out Rect top)
        {
            float split = y.Min(item.yMax);

            bottom = RectExtensions.CreateStrictMinMaxRect(item.min, item.max.GetWithY(split));
            top    = RectExtensions.CreateStrictMinMaxRect(item.min.GetWithY(split), item.max);
        }
Пример #5
0
 static public Rect GetWorldRect(this BoxCollider2D item)
 {
     return(RectExtensions.CreateCenterRect(
                item.transform.TransformPoint(item.offset),
                item.transform.TransformVector(item.size)
                ));
 }
Пример #6
0
 static public Rect GetOrthographicWorldRect(this Camera item)
 {
     return(RectExtensions.CreateMinMaxRect(
                item.GetOrthographicWorldLeftBottom(),
                item.GetOrthographicWorldRightTop()
                ));
 }
Пример #7
0
 static public Rect GetSizedAnchorMax(this Rect item, Vector2 size)
 {
     return(RectExtensions.CreateMinMaxRect(
                item.max - size,
                item.max
                ));
 }
Пример #8
0
 static public Rect GetTopExtrusion(this Rect item, float amount)
 {
     return(RectExtensions.CreateMinMaxRect(
                item.xMin,
                item.yMax,
                item.xMax,
                item.yMax + amount
                ));
 }
Пример #9
0
 static public Rect GetBottomExtrusion(this Rect item, float amount)
 {
     return(RectExtensions.CreateMinMaxRect(
                item.xMin,
                item.yMin - amount,
                item.xMax,
                item.yMin
                ));
 }
Пример #10
0
        static public Rect GetEncompassing(this Rect item, Rect rect)
        {
            return(RectExtensions.CreateStrictMinMaxRect(
                       item.xMin.Min(rect.xMin),
                       item.yMin.Min(rect.yMin),

                       item.xMax.Max(rect.xMax),
                       item.yMax.Max(rect.yMax)
                       ));
        }
Пример #11
0
        static public bool TryGetIntersection(this Rect item, Rect rect, out Rect intersection)
        {
            return(RectExtensions.TryCreateStrictMinMaxRect(
                       item.xMin.Max(rect.xMin),
                       item.yMin.Max(rect.yMin),

                       item.xMax.Min(rect.xMax),
                       item.yMax.Min(rect.yMax),
                       out intersection
                       ));
        }
Пример #12
0
        static public IEnumerable <Rect> GetSubtraction(this Rect item, Rect to_subtract)
        {
            if (item.TryGetIntersection(to_subtract, out to_subtract) == false)
            {
                yield return(new Rect(item));
            }
            else
            {
                Rect left;
                if (RectExtensions.TryCreateStrictMinMaxRect(
                        item.xMin, to_subtract.yMin,
                        to_subtract.xMin, to_subtract.yMax,
                        out left
                        ))
                {
                    yield return(left);
                }

                Rect right;
                if (RectExtensions.TryCreateStrictMinMaxRect(
                        to_subtract.xMax, to_subtract.yMin,
                        item.xMax, to_subtract.yMax,
                        out right
                        ))
                {
                    yield return(right);
                }

                Rect bottom;
                if (RectExtensions.TryCreateStrictMinMaxRect(
                        item.xMin, item.yMin,
                        item.xMax, to_subtract.yMin,
                        out bottom
                        ))
                {
                    yield return(bottom);
                }

                Rect top;
                if (RectExtensions.TryCreateStrictMinMaxRect(
                        item.xMin, to_subtract.yMax,
                        item.xMax, item.yMax,
                        out top
                        ))
                {
                    yield return(top);
                }
            }
        }
Пример #13
0
        static public Rect DrawSprite(Rect rect, Sprite sprite)
        {
            if (sprite != null)
            {
                rect = RectExtensions.CreateCenterRect(rect.center, sprite.GetTextureSize().GetFilledDimension(rect.size));

                GUI.DrawTextureWithTexCoords(
                    rect,
                    sprite.texture,
                    sprite.GetNormalizedTextureRect()
                    );
            }

            return(rect);
        }
Пример #14
0
 static public Rect GetAdjusted(this Rect item, float x_min_adjust, float y_min_adjust, float x_max_adjust, float y_max_adjust)
 {
     return(RectExtensions.CreateStrictMinMaxRect(item.xMin + x_min_adjust, item.yMin + y_min_adjust, item.xMax + x_max_adjust, item.yMax + y_max_adjust));
 }
Пример #15
0
 static public Rect GetRect(this Vector2 item)
 {
     return(RectExtensions.CreateCenterRect(item, Vector2.zero));
 }
Пример #16
0
 static public Rect GetRect(this Triangle2 item)
 {
     return(RectExtensions.CreatePoints(item.GetPoints()));
 }
Пример #17
0
 static public void SetPixelSizeCentered(this Camera item, Vector2 size)
 {
     item.pixelRect = RectExtensions.CreateCenterRect(ScreenExtensions.GetCenter(), size);
 }
Пример #18
0
 static public Rect GetSizedAnchorCenter(this Rect item, Vector2 size)
 {
     return(RectExtensions.CreateCenterRect(item.center, size));
 }
Пример #19
0
 static public Rect GetLocalRect(this BoxCollider2D item)
 {
     return(RectExtensions.CreateCenterRect(item.offset, item.size));
 }
Пример #20
0
 static public Rect GetRect(this Face item)
 {
     return(RectExtensions.CreateMinMaxRect(item.v0, item.v1));
 }
Пример #21
0
 static public Rect GetArear(this Bounds item)
 {
     return(RectExtensions.CreateMinMaxRect(item.min.GetArear(), item.max.GetArear()));
 }
Пример #22
0
 public Rect GetRect()
 {
     return(RectExtensions.CreateCenterRect(this.GetPlanarPosition(), size));
 }
Пример #23
0
 static public Rect GetSpriteSpaceRect(this Sprite item)
 {
     return(RectExtensions.CreateCenterRect(Vector2.zero, item.GetTextureSize()));
 }