Skip to content

Commit baf1c70

Browse files
committed
added Rect.ByCenter
1 parent a0c233a commit baf1c70

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Runtime/Extensions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,10 @@ public static Vector2 Lerp( this Rect r, Vector2 tPos ) =>
505505
/// <summary>The y axis range of this rectangle</summary>
506506
/// <param name="rect">The rectangle to get the y range of</param>
507507
public static FloatRange RangeY( this Rect rect ) => ( rect.yMin, rect.yMax );
508+
509+
/// <summary>Places the center of this rectangle at its position,
510+
/// useful together with the constructor to define it by center instead of by corner</summary>
511+
public static Rect ByCenter( this Rect r ) => new Rect( r ) { center = r.position };
508512

509513
#endregion
510514

0 commit comments

Comments
 (0)