Legacy Documentation: Version 5.1
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

EditorGUIUtility.RGBToHSV

Suggest a change

Success!

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.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public static function RGBToHSV(rgbColor: Color, out H: float, out S: float, out V: float): void;
public static void RGBToHSV(Color rgbColor, out float H, out float S, out float V);

Parameters

rgbColor The color to convert from.
H The hue of the color is written to this variable.
S The saturation of the color is written to this variable.
V The value of the color is written to this variable.

Description

Convert a color from RGB to HSV color space.

All values are in the 0-1 range

See Also: HSVToRGB.

// 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; } }