public class ColorUtility
{
public ColorUtility();
//
// 摘要:
// Returns the color as a hexadecimal string in the format "RRGGBB".
//
// 参数:
// color:
// The color to be converted.
//
// 返回结果:
// Hexadecimal string representing the color.
public static string ToHtmlStringRGB(Color color);//通过颜色转化为十六进制
//
// 摘要:
// Returns the color as a hexadecimal string in the format "RRGGBBAA".
//
// 参数:
// color:
// The color to be converted.
//
// 返回结果:
// Hexadecimal string representing the color.
public static string ToHtmlStringRGBA(Color color);//R:red红色,G:green蓝色,B:Blue绿色,A代表透明度,(0,0,0)黑,(255,255,255)白,三色的颜色值一样为灰色
public static bool TryParseHtmlString(string htmlString, out Color color);//把十六进制转化为颜色并输出到color
}
改变背景的颜色
ColorUtility.TryParseHtmlString("#CCEEFFFF", out tempColor);//将16位解析输出到颜色对象
bgImage.color = tempColor;//设置背景的颜色