-
Notifications
You must be signed in to change notification settings - Fork 0
/
AuXtraUiExtensions.cs
76 lines (61 loc) · 2.42 KB
/
AuXtraUiExtensions.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
using UnityEngine;
using UnityEngine.UI;
public static class auXtraUiExtensions
{
public static void setTextFieldColors(InputField mInputField,
Color normalColor, Color highlightColor, Color pressedColor){
ColorBlock theColors = mInputField.colors;
theColors.normalColor = normalColor;
theColors.highlightedColor = highlightColor;
theColors.pressedColor = pressedColor;
mInputField.colors = theColors;
}
public static void setButtonColors(Button mButton,
Color normalColor, Color highlightColor, Color pressedColor){
ColorBlock theColors = mButton.colors;
theColors.normalColor = normalColor;
theColors.highlightedColor = highlightColor;
theColors.pressedColor = pressedColor;
mButton.colors = theColors;
}
public static void setToggleColors(Toggle mToggle,
Color normalColor, Color highlightColor, Color pressedColor){
ColorBlock theColors = mToggle.colors;
theColors.normalColor = normalColor;
theColors.highlightedColor = highlightColor;
theColors.pressedColor = pressedColor;
mToggle.colors = theColors;
}
public static void setScrollbarColors(Scrollbar mScrollbar,
Color normalColor, Color highlightColor, Color pressedColor){
ColorBlock theColors = mScrollbar.colors;
theColors.normalColor = normalColor;
theColors.highlightedColor = highlightColor;
theColors.pressedColor = pressedColor;
mScrollbar.colors = theColors;
}
public static void setDropdownColors(Dropdown mDropdown,
Color normalColor, Color highlightColor, Color pressedColor, Color bgColor){
setUiImageColor (mDropdown.template.GetComponent<Image> (), bgColor);
setToggleColors(mDropdown.template.GetComponentInChildren<Toggle>(),normalColor, highlightColor, pressedColor);
setScrollbarColors(mDropdown.template.GetComponentInChildren<Scrollbar>(),normalColor, highlightColor, pressedColor);
ColorBlock theColors = mDropdown.colors;
theColors.normalColor = normalColor;
theColors.highlightedColor = highlightColor;
theColors.pressedColor = pressedColor;
mDropdown.colors = theColors;
}
public static void setUiImageColor(Image mImage, Color bgColor){
mImage.color = bgColor;
}
// https://forum.unity.com/threads/changing-a-new-ui-images-alpha-value.289755/#post-2699525
public static void SetTransparency(UnityEngine.UI.Image p_image, float p_transparency)
{
if (p_image != null)
{
UnityEngine.Color __alpha = p_image.color;
__alpha.a = p_transparency;
p_image.color = __alpha;
}
}
}