Class Vector2Extensions
UnityEngine.Vector2 Based Extension Methods
Inheritance
Namespace: GDX
Syntax
[VisualScriptingCompatible((short)2)]
public static class Vector2Extensions
Methods
| Improve this Doc View SourceApproximately(Vector2, Vector2)
Is one UnityEngine.Vector2 approximately similar to another UnityEngine.Vector2?
Declaration
public static bool Approximately(this Vector2 targetVector2, Vector2 otherVector2)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector2 | targetVector2 | Point A |
UnityEngine.Vector2 | otherVector2 | Point B |
Returns
Type | Description |
---|---|
System.Boolean | Are the two UnityEngine.Vector2 approximately the same? |
Remarks
Includes optimized Unity.Mathematics approach.
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |
Midpoint(Vector2, Vector2)
Get the midpoint between two UnityEngine.Vector2s.
Declaration
public static Vector2 Midpoint(this Vector2 targetVector2, Vector2 otherVector2)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector2 | targetVector2 | Point A |
UnityEngine.Vector2 | otherVector2 | Point B |
Returns
Type | Description |
---|---|
UnityEngine.Vector2 | The midpoint between |
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |
NearestIndex(Vector2, Vector2[])
Find the index of the UnityEngine.Vector2 in otherVector2
that is nearest to the
targetVector2
.
Declaration
public static int NearestIndex(this Vector2 targetVector2, Vector2[] otherVector2)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector2 | targetVector2 | The UnityEngine.Vector2 to use as the point of reference. |
UnityEngine.Vector2[] | otherVector2 | An array of UnityEngine.Vector2 positions to evaluate for which one is nearest. |
Returns
Type | Description |
---|---|
System.Int32 | The index of the nearest |
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |
Slope(Vector2)
Get the slope of a UnityEngine.Vector2.
Declaration
public static float Slope(this Vector2 targetVector2)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector2 | targetVector2 | The UnityEngine.Vector2 to evaluate. |
Returns
Type | Description |
---|---|
System.Single | The slope value. |
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |
TryParseVector2(String, out Vector2)
Attempt to parse a System.String into a UnityEngine.Vector2.
Declaration
public static bool TryParseVector2(this string targetString, out Vector2 outputVector2)
Parameters
Type | Name | Description |
---|---|---|
System.String | targetString | The System.String to convert into a UnityEngine.Vector2 if possible. |
UnityEngine.Vector2 | outputVector2 | The outputted UnityEngine.Vector2. |
Returns
Type | Description |
---|---|
System.Boolean | true/false if the conversion was successful. |
Remarks
This isn't great for runtime performance, it should be used predominantly when reconstructing data.
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |