UnityEngine.ColorUtility.ToHtmlStringRGBA C# (CSharp) Method

ToHtmlStringRGBA() public static method

Returns the color as a hexadecimal string in the format "RRGGBBAA".

public static ToHtmlStringRGBA ( Color color ) : string
color Color The color to be converted.
return string
        public static string ToHtmlStringRGBA(Color color)
        {
            Color32 color2 = new Color32((byte) Mathf.Clamp(Mathf.RoundToInt(color.r * 255f), 0, 0xff), (byte) Mathf.Clamp(Mathf.RoundToInt(color.g * 255f), 0, 0xff), (byte) Mathf.Clamp(Mathf.RoundToInt(color.b * 255f), 0, 0xff), (byte) Mathf.Clamp(Mathf.RoundToInt(color.a * 255f), 0, 0xff));
            return string.Format("{0:X2}{1:X2}{2:X2}{3:X2}", new object[] { color2.r, color2.g, color2.b, color2.a });
        }