16 public static class GuiRectUtil {
18 public static Vector3 Corner00(
this Rect rect) {
19 return new Vector3(rect.x, rect.y);
22 public static Vector3 Corner10(
this Rect rect) {
23 return new Vector3(rect.x + rect.width, rect.y);
26 public static Vector3 Corner01(
this Rect rect) {
27 return new Vector3(rect.x, rect.y + rect.height);
30 public static Vector3 Corner11(
this Rect rect) {
31 return new Vector3(rect.x + rect.width, rect.y + rect.height);
34 public static Rect Encapsulate(
this Rect rect, Vector2 point) {
35 if (point.x < rect.x) {
36 rect.width += rect.x - point.x;
38 }
else if (point.x > rect.x + rect.width) {
39 rect.width = point.x - rect.x;
42 if (point.y < rect.y) {
43 rect.height += rect.y - point.y;
45 }
else if (point.y > rect.y + rect.height) {
46 rect.height = point.y - rect.y;
52 public static void SplitHorizontally(
this Rect rect, out Rect left, out Rect right) {
56 right.x += right.width;
59 public static void SplitHorizontallyWithRight(
this Rect rect, out Rect left, out Rect right,
float rightWidth) {
61 left.width -= rightWidth;
63 right.x += right.width;
64 right.width = rightWidth;
67 public static Rect NextLine(
this Rect rect) {
68 rect.y += rect.height;
72 public static Rect FromRight(
this Rect rect,
float width) {
73 rect.x = rect.width - width;
79 public static Rect
SingleLine(
this Rect rect) {
80 rect.height = EditorGUIUtility.singleLineHeight;
84 public static Rect Indent(
this Rect rect) {
85 rect.x += EditorGUIUtility.singleLineHeight;
86 rect.width -= EditorGUIUtility.singleLineHeight;