/// <summary> /// Inverts the rectangle's Y coordinates in screen space. Useful when /// the rectangle needs to be expressed in coordinate systems with the /// Y axis going either up or down. /// </summary> public static Rect InvertScreenY(this Rect rect) { Vector2 center = rect.center; center.y = Screen.height - 1 - center.y; return(RectEx.FromCenterAndSize(center, rect.size)); }
/// <summary> /// Places 'rect' below 'other' and sets its center to the same center /// as 'other' horizontally. /// </summary> public static Rect PlaceBelowCenterHrz(this Rect rect, Rect other) { float centerX = other.center.x; float centerY = other.center.y - other.size.y * 0.5f - rect.size.y * 0.5f; return(RectEx.FromCenterAndSize(new Vector2(centerX, centerY), rect.size)); }