1.如何修改UI的颜色
我们知道unity的ui文字是可以修改颜色的,下面是代码
GUIStyle col = new GUIStyle();//先new一个对象
col.normal.textColor = Color.green;//更改颜色
GUI.Label(new Rect(Screen.width - 120, 40, 100, 40), "旋转",col);
//Label 中的参数一 是位置 参数二 名字 参数三 GUIStyle
//Rect 参数一 位置x 参数二 位置y 参数三 宽度 参数四高度
2.也可以直接在场景中创建text
private Text scoretest;//创建一个私有的text scoretest = GetComponent<Text>();//获取text组件 void getscore() { scoretest.text = "Cube";//代码创建的string的文字会覆盖原来场景上的文字 scoretest.color = Color.red; }
最后在update调用方法就可以了