如何在unity中改变按钮的颜色?

问题描述 投票:0回答:1

我想在语句为真时改变按钮的颜色。

 void Start()
     {
         if ((int.Parse(gameObject.name)) >= GameController.Instance.CurrentLevel + 1)
         {
             gameObject.GetComponent<Image>().color = new Color(96, 96, 96, 255);
         }
     }

我以为是这样的,但是加载后颜色不会改变。有人看到这个问题了吗?

c# unity3d parsing button colors
1个回答
0
投票

Unity的Color classconstructor接受范围从0到1的浮点数,而不是0-255。相应地改变它们,你应该会看到想要的结果。

© www.soinside.com 2019 - 2024. All rights reserved.