Class
- Namespace
- CoreFramework
Provides extension methods for the UnityEngine.Vector2 structure, enabling additional functionality such as component modifications, range checks, and generating random points within specified areas.
public static class Vector2Extensions
- Inheritance
-
object
Methods
Add(Vector2, float, float)
Adds to any x y values of a Vector2
public static Vector2 Add(this Vector2 vector2, float x = 0, float y = 0)
Parameters
vector2
Vector2x
floaty
float
Returns
InRangeOf(Vector2, Vector2, float)
Returns a Boolean indicating whether the current Vector2 is in a given range from another Vector2
public static bool InRangeOf(this Vector2 current, Vector2 target, float range)
Parameters
current
Vector2The current Vector2 position
target
Vector2The Vector2 position to compare against
range
floatThe range value to compare against
Returns
- bool
True if the current Vector2 is in the given range from the target Vector2, false otherwise
RandomPointInAnnulus(Vector2, float, float)
Computes a random point in an annulus (a ring-shaped area) based on minimum and maximum radius values around a central Vector2 point (origin).
public static Vector2 RandomPointInAnnulus(this Vector2 origin, float minRadius, float maxRadius)
Parameters
origin
Vector2The center Vector2 point of the annulus.
minRadius
floatMinimum radius of the annulus.
maxRadius
floatMaximum radius of the annulus.
Returns
- Vector2
A random Vector2 point within the specified annulus.
With(Vector2, float?, float?)
Sets any x y values of a Vector2
public static Vector2 With(this Vector2 vector2, float? x = null, float? y = null)
Parameters
vector2
Vector2x
float?y
float?