我想在语句为真时改变按钮的颜色。
void Start()
{
if ((int.Parse(gameObject.name)) >= GameController.Instance.CurrentLevel + 1)
{
gameObject.GetComponent<Image>().color = new Color(96, 96, 96, 255);
}
}
我以为是这样的,但是加载后颜色不会改变。有人看到这个问题了吗?
Unity的Color classconstructor接受范围从0到1的浮点数,而不是0-255。相应地改变它们,你应该会看到想要的结果。