Unity color hex to hsv

/// <summary>
        /// 颜色hex转hsv
        /// </summary>
        /// <param name="colorValue">注意传入时在十六进制前需要带“#”,例如“#FFFFFF”</param>
        /// <param name="hsvVec">0~1</param>
        public static void ColorHexToHsv(string colorValue, out Vector3 hsvVec)
        {
    
    
            Color rgbColor;

            //rgb 0~1
            ColorUtility.TryParseHtmlString(colorValue, out rgbColor);

            //rgb 0~1
            //hsv 0~1
            Color.RGBToHSV(rgbColor, out hsvVec.x, out hsvVec.y, out hsvVec.z);
        }

Guess you like

Origin blog.csdn.net/weixin_47819574/article/details/131292252