UnityEngine.ColorExtensions.HexString C# (CSharp) Method

HexString() public static method

public static HexString ( Color32 aColor, bool includeAlpha ) : string
aColor Color32
includeAlpha bool
return string
        public static string HexString(Color32 aColor,
                bool includeAlpha)
        {
            String rs = Convert.ToString(aColor.r, 16).ToUpper();
            String gs = Convert.ToString(aColor.g, 16).ToUpper();
            String bs = Convert.ToString(aColor.b, 16).ToUpper();
            String a_s = Convert.ToString(aColor.a, 16).ToUpper();
            while (rs.Length < 2) rs = "0" + rs;
            while (gs.Length < 2) gs = "0" + gs;
            while (bs.Length < 2) bs = "0" + bs;
            while (a_s.Length < 2) a_s = "0" + a_s;
            if (includeAlpha) return "#" + rs + gs + bs + a_s;
            return "#" + rs + gs + bs;
        }

Same methods

ColorExtensions::HexString ( Color aColor ) : string
ColorExtensions::HexString ( Color aColor, bool includeAlpha ) : string