UnityAPI手册-2019.4官网版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
Color.HSVToRGB
# [Color](https://docs.unity3d.com/cn/2019.4/ScriptReference/Color.html).HSVToRGB public static [Color](https://docs.unity3d.com/cn/2019.4/ScriptReference/Color.html) **HSVToRGB** (float **H**, float **S**, float **V**); public static [Color](https://docs.unity3d.com/cn/2019.4/ScriptReference/Color.html) **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 与输入匹配的不透明颜色。 ## 描述 用 HSV 输入创建 RGB 颜色。 用输入的色调、饱和度和明度创建 RGB 颜色。 ``` //Create three Sliders ( Create>UI>Slider) //These are for manipulating the hue, saturation and value levels of the Color. //Attach this script to a GameObject. Make sure it has a Renderer component. //Click on the GameObject and attach each of the Sliders and Texts to the fields in the Inspector. 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); } } ```
da
2022年5月25日 10:59
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码