-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathVectorExtensions.cs
73 lines (64 loc) · 2.11 KB
/
VectorExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
namespace UnityEngine
{
public static class VectorExtensions
{
public static void Deconstruct(in this Vector2 self, out float x, out float y)
{
x = self.x;
y = self.y;
}
public static void Deconstruct(in this Vector3 self, out float x, out float y, out float z)
{
x = self.x;
y = self.y;
z = self.z;
}
public static void Deconstruct(in this Vector4 self, out float x, out float y, out float z, out float w)
{
x = self.x;
y = self.y;
z = self.z;
w = self.w;
}
public static void Deconstruct(in this Vector2Int self, out int x, out int y)
{
x = self.x;
y = self.y;
}
public static void Deconstruct(in this Vector3Int self, out int x, out int y, out int z)
{
x = self.x;
y = self.y;
z = self.z;
}
public static Vector2 With(in this Vector2 self, float? x = null, float? y = null)
=> new Vector2(
x ?? self.x,
y ?? self.y
);
public static Vector3 With(in this Vector3 self, float? x = null, float? y = null, float? z = null)
=> new Vector3(
x ?? self.x,
y ?? self.y,
z ?? self.z
);
public static Vector4 With(in this Vector4 self, float? x = null, float? y = null, float? z = null, float? w = null)
=> new Vector4(
x ?? self.x,
y ?? self.y,
z ?? self.z,
w ?? self.w
);
public static Vector2Int With(in this Vector2Int self, int? x = null, int? y = null)
=> new Vector2Int(
x ?? self.x,
y ?? self.y
);
public static Vector3Int With(in this Vector3Int self, int? x = null, int? y = null, int? z = null)
=> new Vector3Int(
x ?? self.x,
y ?? self.y,
z ?? self.z
);
}
}