forked from laicasaane/unity-supplements
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColorExtensions.cs
51 lines (46 loc) · 1.44 KB
/
ColorExtensions.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
namespace UnityEngine
{
public static class ColorExtensions
{
public static void Deconstruct(in this Color self, out float r, out float g, out float b)
{
r = self.r;
g = self.g;
b = self.b;
}
public static void Deconstruct(in this Color self, out float r, out float g, out float b, out float a)
{
r = self.r;
g = self.g;
b = self.b;
a = self.a;
}
public static void Deconstruct(in this Color32 self, out byte r, out byte g, out byte b)
{
r = self.r;
g = self.g;
b = self.b;
}
public static void Deconstruct(in this Color32 self, out byte r, out byte g, out byte b, out byte a)
{
r = self.r;
g = self.g;
b = self.b;
a = self.a;
}
public static Color With(in this Color self, float? r = null, float? g = null, float? b = null, float? a = null)
=> new Color(
r ?? self.r,
g ?? self.g,
b ?? self.b,
a ?? self.a
);
public static Color32 With(in this Color32 self, byte? r = null, byte? g = null, byte? b = null, byte? a = null)
=> new Color32(
r ?? self.r,
g ?? self.g,
b ?? self.b,
a ?? self.a
);
}
}