Struct RectRange
Represents a rectangle (with its bottom-left corner as the origin).
Properties
width
The width of the rectangle.
public float width { get; }
height
The height of the rectangle.
public float height { get; }
centerX
The X coordinate of the rectangle's center.
public float centerX { get; }
centerY
The Y coordinate of the rectangle's center.
public float centerY { get; }
halfWidth
Half of the rectangle's width.
public float halfWidth { get; }
halfHeight
Half of the rectangle's height.
public float halfHeight { get; }
top
The top (maximum Y) of the rectangle.
public float top { get; }
left
The left (minimum X) of the rectangle.
public float left { get; }
right
The right (maximum X) of the rectangle.
public float right { get; }
bottom
The bottom (minimum Y) of the rectangle.
public float bottom { get; }
size
The width and height of the rectangle.
public Vector2 size { get; }
center
The center point of the rectangle.
public Vector2 center { get; }
Constructors
RectRange(Vector2 origin, Vector2 size)
public RectRange(Vector2 origin, Vector2 size)
RectRange()
public RectRange()
Methods
CreateRectRangeByTwoPoints(Vector2 bottomLeft, Vector2 upRight)
Creates a winS.Unity.RectRange by its bottom-left and top-right corners.
public static RectRange CreateRectRangeByTwoPoints(Vector2 bottomLeft, Vector2 upRight)
Contains(Vector2 point)
Determines whether the rectangle contains the given point.
public bool Contains(Vector2 point)
Overlaps(RectRange another)
Determines whether this rectangle overlaps another.
public bool Overlaps(RectRange another)
Restriction(Vector2 point, Vector2 newPoint)
If the given point is outside the rectangle, the nearest point within the rectangle is returned; otherwise it is returned unchanged.
public bool Restriction(Vector2 point, Vector2 newPoint)
RaycastRect(Vector2 point, Vector2 direction, Vector2 hitPoint, [bool normalize = true])
Casts a ray from point in direction and returns the first intersection point with the rectangle boundary.
public bool RaycastRect(Vector2 point, Vector2 direction, Vector2 hitPoint, [bool normalize = true])
ToString()
public override string ToString()