7 [RequireComponent(typeof(
BoxSlider), typeof(RawImage)), ExecuteInEditMode()]
13 private RawImage image;
15 private float lastH = -1;
16 private bool listen =
true;
28 slider = GetComponent<BoxSlider>();
29 image = GetComponent<RawImage>();
31 RegenerateSVTexture();
34 private void OnEnable()
36 if (Application.isPlaying &&
picker !=
null)
43 private void OnDisable()
52 private void OnDestroy()
54 if (image.texture !=
null)
55 DestroyImmediate(image.texture);
59 private void OnValidate()
61 image = GetComponent<RawImage>();
62 RegenerateSVTexture();
66 private void SliderChanged(
float saturation,
float value)
76 private void HSVChanged(
float h,
float s,
float v)
81 RegenerateSVTexture();
97 private void RegenerateSVTexture()
101 if (image.texture !=
null)
102 DestroyImmediate(image.texture);
104 Texture2D texture =
new Texture2D(100, 100)
106 hideFlags = HideFlags.DontSave
108 for (
int s = 0; s < 100; s++)
110 Color32[] colors =
new Color32[100];
111 for (
int v = 0; v < 100; v++)
113 colors[v] = HSVUtil.ConvertHsvToRgb(h, (
float)s / 100, (
float)v / 100, 1);
115 texture.SetPixels32(s, 0, 1, 100, colors);
119 image.texture = texture;
BoxSliderEvent OnValueChanged
HSVChangedEvent onHSVChanged
void AssignColor(ColorValues type, float value)
RectTransform RectTransform
ColorPickerControl picker