Select your preferred scripting language. All code snippets will be displayed in this language.
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Closeh | The hue of the color - in the range 0 to 1. |
s | The saturation of the color. |
v | The value of the color. |
Color The RGB color calculated from the HSV values passed into the function. The alpha value of the color will be 1.
Convert a set of HSV values to an RGB Color.
All values are in the range 0 - 1.
See Also: RGBToHSV.
// Simple script that shows the color info on // RGB (Red Green Blue) values and // HSV (Hue Saturation Value) values.
class RGBHSVInfo extends Editor{ @MenuItem("Examples/Color Info") static function CheckColor() { var h : float = 0; var s : float = 0; var v : float = 0; var objColor : Color = Color.white; var obj = Selection.activeGameObject; var rend = obj.GetComponent.<Renderer>(); if(!rend.material) { Debug.LogError("Selected Object doesnt have a material."); return; } objColor = rend.sharedMaterial.color; EditorGUIUtility.RGBToHSV(objColor,h,s,v); objColor = EditorGUIUtility.HSVToRGB(h,s,v); Debug.Log("RGB: " + objColor.r + "," + objColor.g + "," + objColor.b); Debug.Log("HSV: " + h + "," + s + "," + v); } @MenuItem("Examples/Color Info", true) static function ValidateCheckColor() { return Selection.activeGameObject != null; } }