Объявление
public static Color HSVToRGB(float H, float S, float V);public static Color HSVToRGB(float H, float S, float V, bool hdr);
Параметры
H | оттенок [0..1]. |
S | Насыщенность [0..1]. |
V | Значение яркости [0..1]. |
hdr | Вывод цветов HDR. Если true, возвращаемый цвет не будет привязан к [0..1]. |
Возвращает
Color Непрозрачный цвет с HSV, соответствующим входным данным.
Описание
Создает цвет RGB из входных данных HSV.
Создает цвет RGB из оттенка, насыщенности и значения входных данных.
//Создаем три ползунка ( Create>UI>Slider)
//Они предназначены для управления оттенком, насыщенностью и уровнями значений Color.
//Прикрепите этот скрипт к GameObject. Убедитесь, что у него есть компонент Renderer.
//Нажмите на GameObject и прикрепите каждый слайдер и текст к полям в Инспекторе.
using UnityEngine;
using UnityEngine.UI;
public class ColorHSVtoRGBExample : MonoBehaviour
{
float m_Hue;
float m_Saturation;
float m_Value;
//These are the Sliders that control the values. Remember to attach them in the Inspector window.
public Slider m_SliderHue, m_SliderSaturation, m_SliderValue;
//Make sure your GameObject has a Renderer component in the Inspector window
Renderer m_Renderer;
void Start()
{
//Fetch the Renderer component from the GameObject with this script attached
m_Renderer = GetComponent<Renderer>();
//Set the maximum and minimum values for the Sliders
m_SliderHue.maxValue = 1;
m_SliderSaturation.maxValue = 1;
m_SliderValue.maxValue = 1;
m_SliderHue.minValue = 0;
m_SliderSaturation.minValue = 0;
m_SliderValue.minValue = 0;
}
void Update()
{
//These are the Sliders that determine the amount of the hue, saturation and value in the Color
m_Hue = m_SliderHue.value;
m_Saturation = m_SliderSaturation.value;
m_Value = m_SliderValue.value;
//Create an RGB color from the HSV values from the Sliders
//Change the Color of your GameObject to the new Color
m_Renderer.material.color = Color.HSVToRGB(m_Hue, m_Saturation, m_Value);
}
}