EditorGUIUtility.RGBToHSV 转换颜色RGB到HSV

static function RGBToHSV (rgbColor : Color, out H : float, out S : float, out V : float) : void

Parameters参数

Description描述

Convert a color from RGB to HSV color space.

转换颜色从RGB 到 HSV颜色空间。

All values are in the 0-1 range

所有值的范围在0-1之间。

参见: HSVToRGB

// Simple script that shows the color info on
// RGB (Red Green Blue) values and
// HSV (Hue Saturation Value) values.
//显示RGB和HSV颜色信息
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.renderer;
		if(!obj.renderer.material) {
			Debug.LogError("Selected Object doesnt have a material.");
			return;
		}
		objColor = obj.renderer.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;
	}
}
最后修改:2011年7月15日 Friday 13:05

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。