Skip to content

Commit e665951

Browse files
Updated Picker control and samples to latest
1 parent 70af128 commit e665951

File tree

5 files changed

+27
-30
lines changed

5 files changed

+27
-30
lines changed

Runtime/Scripts/Controls/ColorPicker/ColorImage.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@
55
namespace UnityEngine.UI.Extensions.ColorPicker
66
{
77
[RequireComponent(typeof(Image))]
8-
public class ColorImage : MonoBehaviour
9-
{
10-
public ColorPickerControl picker;
8+
public class ColorImage : MonoBehaviour
9+
{
10+
public ColorPickerControl picker;
1111

12-
private Image image;
12+
private Image image;
1313

14-
private void Awake()
15-
{
16-
image = GetComponent<Image>();
17-
picker.onValueChanged.AddListener(ColorChanged);
18-
}
14+
private void Awake()
15+
{
16+
image = GetComponent<Image>();
17+
picker.onValueChanged.AddListener(ColorChanged);
18+
}
1919

20-
private void OnDestroy()
21-
{
22-
picker.onValueChanged.RemoveListener(ColorChanged);
23-
}
20+
private void OnDestroy()
21+
{
22+
picker.onValueChanged.RemoveListener(ColorChanged);
23+
}
2424

25-
private void ColorChanged(Color newColor)
26-
{
27-
image.color = newColor;
25+
private void ColorChanged(Color newColor)
26+
{
27+
image.color = newColor;
28+
}
2829
}
29-
}
3030
}

Runtime/Scripts/Controls/ColorPicker/ColorLabel.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace UnityEngine.UI.Extensions.ColorPicker
66
{
7-
87
[RequireComponent(typeof(TMPro.TMP_Text))]
98
public class ColorLabel : MonoBehaviour
109
{
@@ -51,7 +50,7 @@ private void ColorChanged(Color color)
5150
UpdateValue();
5251
}
5352

54-
private void HSVChanged(float hue, float sateration, float value)
53+
private void HSVChanged(float hue, float saturation, float value)
5554
{
5655
UpdateValue();
5756
}

Runtime/Scripts/Controls/ColorPicker/ColorSampler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class ColorSampler : MonoBehaviour, IPointerDownHandler, IPointerUpHandle
2727

2828
protected Texture2D screenCapture;
2929

30-
public ColorChangedEvent oncolorSelected = new ColorChangedEvent();
30+
public ColorChangedEvent onColorSelected = new ColorChangedEvent();
3131

3232
protected Color color;
3333

@@ -71,8 +71,8 @@ protected virtual void HandleSamplerColoring()
7171

7272
protected virtual void SelectColor()
7373
{
74-
if (oncolorSelected != null)
75-
oncolorSelected.Invoke(color);
74+
if (onColorSelected != null)
75+
onColorSelected.Invoke(color);
7676

7777
enabled = false;
7878
}

Runtime/Scripts/Controls/ColorPicker/HexColorField.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,23 @@
55

66
namespace UnityEngine.UI.Extensions.ColorPicker
77
{
8-
9-
[RequireComponent(typeof(InputField))]
8+
[RequireComponent(typeof(TMPro.TMP_InputField))]
109
public class HexColorField : MonoBehaviour
1110
{
1211
public ColorPickerControl ColorPicker;
1312

1413
public bool displayAlpha;
1514

16-
private InputField hexInputField;
15+
private TMPro.TMP_InputField hexInputField;
1716

1817
private const string hexRegex = "^#?(?:[0-9a-fA-F]{3,4}){1,2}$";
1918

2019
private void Awake()
2120
{
22-
hexInputField = GetComponent<InputField>();
21+
hexInputField = GetComponent<TMPro.TMP_InputField>();
2322

2423
// Add listeners to keep text (and color) up to date
25-
hexInputField.onEndEdit.AddListener(UpdateColor);
24+
hexInputField.onValueChanged.AddListener(UpdateColor);
2625
ColorPicker.onValueChanged.AddListener(UpdateHex);
2726
}
2827

@@ -39,8 +38,7 @@ private void UpdateHex(Color newColor)
3938

4039
private void UpdateColor(string newHex)
4140
{
42-
Color32 color;
43-
if (HexToColor(newHex, out color))
41+
if (HexToColor(newHex, out Color32 color))
4442
ColorPicker.CurrentColor = color;
4543
else
4644
Debug.Log("hex value is in the wrong format, valid formats are: #RGB, #RGBA, #RRGGBB and #RRGGBBAA (# is optional)");

0 commit comments

Comments
 (0)