-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommon.Colors.cs
96 lines (84 loc) · 2.52 KB
/
Common.Colors.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using UnityEngine;
using UnityEngine.UI;
namespace VirtueSky.Misc
{
public partial class Common
{
public static Color SetAlpha(this Color color, float a)
{
color.a = a;
return color;
}
public static Color SetRed(this Color color, float r)
{
color.r = r;
return color;
}
public static Color SetGreen(this Color color, float g)
{
color.g = g;
return color;
}
public static Color SetBlue(this Color color, float b)
{
color.b = b;
return color;
}
public static Graphic SetAlpha(this Graphic graphic, float a)
{
var colorCache = graphic.color;
colorCache.a = a;
graphic.color = colorCache;
return graphic;
}
public static Graphic SetRed(this Graphic graphic, float r)
{
var colorCache = graphic.color;
colorCache.r = r;
graphic.color = colorCache;
return graphic;
}
public static Graphic SetGreen(this Graphic graphic, float g)
{
var colorCache = graphic.color;
colorCache.g = g;
graphic.color = colorCache;
return graphic;
}
public static Graphic SetBlue(this Graphic graphic, float b)
{
var colorCache = graphic.color;
colorCache.b = b;
graphic.color = colorCache;
return graphic;
}
public static SpriteRenderer SetAlpha(this SpriteRenderer renderer, float a)
{
var colorCache = renderer.color;
colorCache.a = a;
renderer.color = colorCache;
return renderer;
}
public static SpriteRenderer SetRed(this SpriteRenderer renderer, float r)
{
var colorCache = renderer.color;
colorCache.r = r;
renderer.color = colorCache;
return renderer;
}
public static SpriteRenderer SetGreen(this SpriteRenderer renderer, float g)
{
var colorCache = renderer.color;
colorCache.g = g;
renderer.color = colorCache;
return renderer;
}
public static SpriteRenderer SetBlue(this SpriteRenderer renderer, float b)
{
var colorCache = renderer.color;
colorCache.b = b;
renderer.color = colorCache;
return renderer;
}
}
}