/// <summary> /// Sets the color. /// </summary> /// <param name="value">Value.</param> protected virtual void SetColor(ColorHSV value) { Diffs.Clear(); if ((ColorRight.H - ColorLeft.H) != 0f) { Diffs.Add(Mathf.Abs((value.H - ColorLeft.H) / (ColorRight.H - ColorLeft.H))); } if ((ColorRight.S - ColorLeft.S) != 0f) { Diffs.Add(Mathf.Abs((value.S - ColorLeft.S) / (ColorRight.S - ColorLeft.S))); } if ((ColorRight.V - ColorLeft.V) != 0f) { Diffs.Add(Mathf.Abs((value.V - ColorLeft.V) / (ColorRight.V - ColorLeft.V))); } if (ColorRight.A != ColorLeft.A) { Diffs.Add(Mathf.Abs((value.A - ColorLeft.A) / (ColorRight.A - ColorLeft.A))); } var t = Diffs.Count == 0 ? 1 : Utilites.Sum(Diffs) / (float)Diffs.Count; color = ColorHSV.Lerp(ColorLeft, ColorRight, t); Slider.value = t * (Slider.maxValue - Slider.minValue); }
/// <summary> /// Values the changed. /// </summary> protected virtual void ValueChanged() { if (inUpdateMode) { return; } color = ColorHSV.Lerp(ColorLeft, ColorRight, Slider.value / (Slider.maxValue - Slider.minValue)); OnChange.Invoke(color); }