Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
HueSlider.cs
Go to the documentation of this file.
1using System;
3using UnityEngine;
4using UnityEngine.UI;
5
7
8public class HueSlider : MonoBehaviour
9{
10 [SerializeField]
12
13 [SerializeField]
14 private RawImage hueSliderBackground;
15
16 public float value
17 {
18 get
19 {
20 return slider.value;
21 }
22 set
23 {
24 slider.SetValue(value, sendEvent: false);
25 }
26 }
27
28 public event Action<float> HueValueChanged = delegate
29 {
30 };
31
32 public void Init()
33 {
34 slider.onValueChanged.AddListener(OnValueChanged);
36 }
37
38 public void OnValueChanged(float value)
39 {
40 this.HueValueChanged(value);
41 }
42
43 private void GenerateSliderTexture()
44 {
45 Color[] array = GenerateHsvSpectrum();
46 Texture2D texture2D = new Texture2D(1, array.Length);
47 for (int i = 0; i < texture2D.height; i++)
48 {
49 texture2D.SetPixel(1, i, array[i]);
50 }
51 texture2D.Apply();
52 hueSliderBackground.texture = texture2D;
53 }
54
55 public static Color[] GenerateHsvSpectrum()
56 {
57 Color[] array = new Color[360];
58 for (int i = 0; i < 360; i++)
59 {
60 array[i] = Colorist.HSVtoRGB(i, 1f, 1f);
61 }
62 return array;
63 }
64
66 {
67 slider.SetValue(value, sendEvent: true);
68 }
69}
Action< float > HueValueChanged
Definition: HueSlider.cs:28
void OnValueChanged(float value)
Definition: HueSlider.cs:38
EventAwareSlider slider
Definition: HueSlider.cs:11
static Color[] GenerateHsvSpectrum()
Definition: HueSlider.cs:55
void SetSliderValueAndSendEvent(float value)
Definition: HueSlider.cs:65
static Color HSVtoRGB(HSVColor hsv)
Definition: Colorist.cs:107
void SetValue(float value, bool sendEvent)