UnityEssentials
Small but useful tools and features for Unity
Static Public Member Functions | List of all members
UnityEngine.VectorExtensions Class Reference

Extensions for Vector More...

Collaboration diagram for UnityEngine.VectorExtensions:
Collaboration graph

Static Public Member Functions

static Vector2 Clone (this Vector2 v)
 Creates a new vector with the same values as the original. More...
 
static Vector2 WithX (this Vector2 v, float x=0f)
 Creates a new vector with the same value for the 'y' parameter but a new one for the 'x'. More...
 
static Vector2 WithY (this Vector2 v, float y=0f)
 Creates a new vector with the same value for the 'x' parameter but a new one for the 'y'. More...
 
static Vector3 ToVector3NewX (this Vector2 v, float x=0f)
 Creates a new Vector3 keeping the values from the 'x' and 'y' parameters of the original Vector2 in that order. More...
 
static Vector3 ToVector3NewY (this Vector2 v, float y=0f)
 Creates a new Vector3 keeping the values from the 'x' and 'y' parameters of the original Vector2 in that order. More...
 
static Vector3 ToVector3NewZ (this Vector2 v, float z=0f)
 Creates a new Vector3 keeping the values from the 'x' and 'y' parameters of the original Vector2 in that order. More...
 
static Vector3 Clone (this Vector3 v)
 Creates a new vector with the same values as the original. More...
 
static Vector2 ToVector2WithoutX (this Vector3 v)
 Creates a new Vector2 keeping the values from the 'y' and 'z' parameters of the original Vector3. More...
 
static Vector2 ToVector2WithoutY (this Vector3 v)
 Creates a new Vector2 keeping the values from the 'x' and 'z' parameters of the original Vector3. More...
 
static Vector2 ToVector2WithoutZ (this Vector3 v)
 Creates a new Vector2 keeping the values from the 'x' and 'y' parameters of the original Vector3. More...
 
static Vector3 WithX (this Vector3 v, float x=0f)
 Creates a new vector with the same value for the 'y' and 'z' parameter but a new one for the 'x'. More...
 
static Vector3 WithY (this Vector3 v, float y=0f)
 Creates a new vector with the same value for the 'x' and 'z' parameter but a new one for the 'y'. More...
 
static Vector3 WithZ (this Vector3 v, float z=0f)
 Creates a new vector with the same value for the 'x' and 'y' parameter but a new one for the 'z'. More...
 
static Vector3 NearestPointOnLine (this Vector3 point, Vector3 origin, Vector3 end, bool clampInsideLineLength=true)
 Calculates the nearest position in a given line or segment. More...
 
static Vector3Int ToVectorInt (this Vector3 v, bool round=false)
 Creates a new Vector3Int with the values in the original vector. More...
 
static Vector2Int ToVectorInt (this Vector2 v, bool round=false)
 Creates a new Vector2Int with the values in the original vector. More...
 

Detailed Description

Extensions for Vector

Definition at line 6 of file VectorExtensions.cs.

Member Function Documentation

◆ Clone() [1/2]

static Vector2 UnityEngine.VectorExtensions.Clone ( this Vector2  v)
static

Creates a new vector with the same values as the original.

Returns
A new vector with the same values as the original.

Definition at line 12 of file VectorExtensions.cs.

◆ Clone() [2/2]

static Vector3 UnityEngine.VectorExtensions.Clone ( this Vector3  v)
static

Creates a new vector with the same values as the original.

Returns
A new vector with the same values as the original.

Definition at line 71 of file VectorExtensions.cs.

◆ NearestPointOnLine()

static Vector3 UnityEngine.VectorExtensions.NearestPointOnLine ( this Vector3  point,
Vector3  origin,
Vector3  end,
bool  clampInsideLineLength = true 
)
static

Calculates the nearest position in a given line or segment.

Parameters
originThe origin point of the segment.
endThe end point of the segment.
clampInsideLineLengthIf the result must be inside the given segment. If false, the origin and end points will be used to calculate the direction of an infinite line and the result will be within it.
Returns
The closest point to the segment or the line depending on the value of the 'clampInsideLineLength parameter.

Definition at line 140 of file VectorExtensions.cs.

◆ ToVector2WithoutX()

static Vector2 UnityEngine.VectorExtensions.ToVector2WithoutX ( this Vector3  v)
static

Creates a new Vector2 keeping the values from the 'y' and 'z' parameters of the original Vector3.

Returns
A new Vector2 with the 'y' and 'z' values equal to the original Vector3.

Definition at line 80 of file VectorExtensions.cs.

◆ ToVector2WithoutY()

static Vector2 UnityEngine.VectorExtensions.ToVector2WithoutY ( this Vector3  v)
static

Creates a new Vector2 keeping the values from the 'x' and 'z' parameters of the original Vector3.

Returns
A new Vector2 with the 'x' and 'z' values equal to the original Vector3.

Definition at line 89 of file VectorExtensions.cs.

◆ ToVector2WithoutZ()

static Vector2 UnityEngine.VectorExtensions.ToVector2WithoutZ ( this Vector3  v)
static

Creates a new Vector2 keeping the values from the 'x' and 'y' parameters of the original Vector3.

Returns
A new Vector2 with the 'x' and 'y' values equal to the original Vector3.

Definition at line 98 of file VectorExtensions.cs.

◆ ToVector3NewX()

static Vector3 UnityEngine.VectorExtensions.ToVector3NewX ( this Vector2  v,
float  x = 0f 
)
static

Creates a new Vector3 keeping the values from the 'x' and 'y' parameters of the original Vector2 in that order.

Parameters
xThe desired value for the 'x' component on the new Vector 3.
Returns
A new Vector3 with the 'x' and 'y' values equal to the original Vector2.

Definition at line 42 of file VectorExtensions.cs.

◆ ToVector3NewY()

static Vector3 UnityEngine.VectorExtensions.ToVector3NewY ( this Vector2  v,
float  y = 0f 
)
static

Creates a new Vector3 keeping the values from the 'x' and 'y' parameters of the original Vector2 in that order.

Parameters
yThe desired value for the 'y' component on the new Vector 3.
Returns
A new Vector3 with the 'x' and 'y' values equal to the original Vector2.

Definition at line 52 of file VectorExtensions.cs.

◆ ToVector3NewZ()

static Vector3 UnityEngine.VectorExtensions.ToVector3NewZ ( this Vector2  v,
float  z = 0f 
)
static

Creates a new Vector3 keeping the values from the 'x' and 'y' parameters of the original Vector2 in that order.

Parameters
zThe desired value for the 'z' component on the new Vector 3.
Returns
A new Vector3 with the 'x' and 'y' values equal to the original Vector2.

Definition at line 62 of file VectorExtensions.cs.

◆ ToVectorInt() [1/2]

static Vector2Int UnityEngine.VectorExtensions.ToVectorInt ( this Vector2  v,
bool  round = false 
)
static

Creates a new Vector2Int with the values in the original vector.

Parameters
roundIf the values should be rounded to the nearest integer.
Returns
A new Vector3Int with the values in the original vector.

Definition at line 176 of file VectorExtensions.cs.

◆ ToVectorInt() [2/2]

static Vector3Int UnityEngine.VectorExtensions.ToVectorInt ( this Vector3  v,
bool  round = false 
)
static

Creates a new Vector3Int with the values in the original vector.

Parameters
roundIf the values should be rounded to the nearest integer.
Returns
A new Vector3Int with the values in the original vector.

Definition at line 164 of file VectorExtensions.cs.

◆ WithX() [1/2]

static Vector2 UnityEngine.VectorExtensions.WithX ( this Vector2  v,
float  x = 0f 
)
static

Creates a new vector with the same value for the 'y' parameter but a new one for the 'x'.

Parameters
xThe desired value for the 'x' component on the new vector.
Returns
A new vector with the same value for the 'y' parameter but a new one for the 'x'.

Definition at line 22 of file VectorExtensions.cs.

◆ WithX() [2/2]

static Vector3 UnityEngine.VectorExtensions.WithX ( this Vector3  v,
float  x = 0f 
)
static

Creates a new vector with the same value for the 'y' and 'z' parameter but a new one for the 'x'.

Parameters
xThe desired value for the 'x' component on the new vector.
Returns
A new vector with the same value for the 'y' and 'z' parameter but a new one for the 'x'.

Definition at line 108 of file VectorExtensions.cs.

◆ WithY() [1/2]

static Vector2 UnityEngine.VectorExtensions.WithY ( this Vector2  v,
float  y = 0f 
)
static

Creates a new vector with the same value for the 'x' parameter but a new one for the 'y'.

Parameters
yThe desired value for the 'y' component on the new vector.
Returns
A new vector with the same value for the 'x' parameter but a new one for the 'y'.

Definition at line 32 of file VectorExtensions.cs.

◆ WithY() [2/2]

static Vector3 UnityEngine.VectorExtensions.WithY ( this Vector3  v,
float  y = 0f 
)
static

Creates a new vector with the same value for the 'x' and 'z' parameter but a new one for the 'y'.

Parameters
yThe desired value for the 'y' component on the new vector.
Returns
A new vector with the same value for the 'x' and 'z' parameter but a new one for the 'y'.

Definition at line 118 of file VectorExtensions.cs.

◆ WithZ()

static Vector3 UnityEngine.VectorExtensions.WithZ ( this Vector3  v,
float  z = 0f 
)
static

Creates a new vector with the same value for the 'x' and 'y' parameter but a new one for the 'z'.

Parameters
zThe desired value for the 'z' component on the new vector.
Returns
A new vector with the same value for the 'x' and 'y' parameter but a new one for the 'z'.

Definition at line 128 of file VectorExtensions.cs.


The documentation for this class was generated from the following file: