UnityEssentials
Small but useful tools and features for Unity
VectorIntExtensions.cs
Go to the documentation of this file.
1 namespace UnityEngine
2 {
6  public static class VectorIntExtensions
7  {
12  public static Vector2Int Clone(this Vector2Int v)
13  {
14  return new Vector2Int(v.x, v.y);
15  }
16 
22  public static Vector2Int WithX(this Vector2Int v, int x = 0)
23  {
24  return new Vector2Int(x, v.y);
25  }
26 
32  public static Vector2Int WithY(this Vector2Int v, int y = 0)
33  {
34  return new Vector2Int(v.x, y);
35  }
36 
42  public static Vector3Int ToVector3IntNewX(this Vector2Int v, int x = 0)
43  {
44  return new Vector3Int(x, v.x, v.y);
45  }
46 
52  public static Vector3Int ToVector3IntNewY(this Vector2Int v, int y = 0)
53  {
54  return new Vector3Int(v.x, y, v.y);
55  }
56 
62  public static Vector3Int ToVector3IntNewZ(this Vector2Int v, int z = 0)
63  {
64  return new Vector3Int(v.x, v.y, z);
65  }
66 
71  public static Vector3Int Clone(this Vector3Int v)
72  {
73  return new Vector3Int(v.x, v.y, v.z);
74  }
75 
80  public static Vector2Int ToVector2IntWithoutX(this Vector3Int v)
81  {
82  return new Vector2Int(v.y, v.z);
83  }
84 
89  public static Vector2Int ToVector2IntWithoutY(this Vector3Int v)
90  {
91  return new Vector2Int(v.x, v.z);
92  }
93 
98  public static Vector2Int ToVector2IntWithoutZ(this Vector3Int v)
99  {
100  return new Vector2Int(v.x, v.y);
101  }
102 
108  public static Vector3Int WithX(this Vector3Int v, int x = 0)
109  {
110  return new Vector3Int(x, v.y, v.z);
111  }
112 
118  public static Vector3Int WithY(this Vector3Int v, int y = 0)
119  {
120  return new Vector3Int(v.x, y, v.z);
121  }
122 
128  public static Vector3Int WithZ(this Vector3Int v, int z = 0)
129  {
130  return new Vector3Int(v.x, v.y, z);
131  }
132 
137  public static Vector3 ToVectorFloat(this Vector3Int v)
138  {
139  return new Vector3(v.x, v.y, v.z);
140  }
141 
146  public static Vector2 ToVectorFloat(this Vector2Int v)
147  {
148  return new Vector2(v.x, v.y);
149  }
150  }
151 }
static Vector3Int WithZ(this Vector3Int v, int z=0)
Creates a new vector with the same value for the 'x' and 'y' parameter but a new one for the 'z'.
static Vector2Int WithY(this Vector2Int v, int y=0)
Creates a new vector with the same value for the 'x' parameter but a new one for the 'y'.
static Vector3Int WithX(this Vector3Int v, int x=0)
Creates a new vector with the same value for the 'y' and 'z' parameter but a new one for the 'x'.
static Vector2 ToVectorFloat(this Vector2Int v)
Creates a new Vector2 with the values in the original vector.
static Vector2Int Clone(this Vector2Int v)
Creates a new vector with the same values as the original.
static Vector3Int Clone(this Vector3Int v)
Creates a new vector with the same values as the original.
static Vector3Int ToVector3IntNewY(this Vector2Int v, int y=0)
Creates a new Vector3Int keeping the values from the 'x' and 'y' parameters of the original Vector2In...
static Vector3Int WithY(this Vector3Int v, int y=0)
Creates a new vector with the same value for the 'x' and 'z' parameter but a new one for the 'y'.
static Vector2Int ToVector2IntWithoutZ(this Vector3Int v)
Creates a new Vector2Int keeping the values from the 'x' and 'y' parameters of the original Vector3In...
static Vector2Int WithX(this Vector2Int v, int x=0)
Creates a new vector with the same value for the 'y' parameter but a new one for the 'x'.
static Vector3 ToVectorFloat(this Vector3Int v)
Creates a new Vector3 with the values in the original vector.
static Vector2Int ToVector2IntWithoutY(this Vector3Int v)
Creates a new Vector2Int keeping the values from the 'x' and 'z' parameters of the original Vector3In...
static Vector2Int ToVector2IntWithoutX(this Vector3Int v)
Creates a new Vector2Int keeping the values from the 'y' and 'z' parameters of the original Vector3In...
static Vector3Int ToVector3IntNewZ(this Vector2Int v, int z=0)
Creates a new Vector3Int keeping the values from the 'x' and 'y' parameters of the original Vector2In...
static Vector3Int ToVector3IntNewX(this Vector2Int v, int x=0)
Creates a new Vector3Int keeping the values from the 'x' and 'y' parameters of the original Vector2In...