Skip to content

Commit

Permalink
Small change to RectUtilities
Browse files Browse the repository at this point in the history
  • Loading branch information
nickc01 committed Jun 29, 2024
1 parent fc00f12 commit 5f3a8f0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions WeaverCore/Utilities/RectUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ public static Vector2 ClampWithin(this Rect rect, Vector2 point)
return new Vector2(Mathf.Clamp(point.x, rect.xMin, rect.xMax), Mathf.Clamp(point.y, rect.yMin, rect.yMax));
}

/// <summary>
/// Clamps a point within a rect
/// </summary>
/// <param name="rect">The rect to clamp the point within</param>
/// <param name="point">The point to clamp</param>
/// <returns>Returns the point clamped within the rect</returns>
public static Vector3 ClampWithin(this Rect rect, Vector3 point)
{
return new Vector3(Mathf.Clamp(point.x, rect.xMin, rect.xMax), Mathf.Clamp(point.y, rect.yMin, rect.yMax), point.z);
}

/// <summary>
/// Gets a random point within a rect
/// </summary>
Expand Down

0 comments on commit 5f3a8f0

Please sign in to comment.