欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

设置UGUI Color 的 RGB值

程序员文章站 2024-03-18 12:52:10
...

Case1 : 直接指定顏色名

Color gray = new color32(80, 80, 80, 255);				//RGB (0-255)
Color gray2 = new color(0.313f, 0.313f, 0.313f, 1); 	//RGB (0-1.0)
	//	gray = gray2

void ChangeColor()
{
	text1.color = gray;
	image1.color = gray2;
}

Case2 : 指定为方法

void ChangeColor(Text text, byte r, byte g, byte b, byte a) 
{
	if ( text != null) 
	{
		text.color  = new color(r, g, b, a);
	}
}