unity lable 处理颜色是怎么做到的,下面我们就学习一下用代码处理lable颜色。
- UILabel m_name = transform.Find("Name").GetComponent<UILabel>();
- m_name.text = GetNameColor(name,1);
- string GetNameColor(string name , int quality)
- {
- string str;
- switch(quality)
- {
- case 1:
- str = "[ffffff]" + name + [-];
- break;
- case 2:
- str = "[00ff00]" + name + [-];
- break;
- case 3:
- str = "[66ccff]" + name + [-];
- break;
- case 4:
- str = "[ff00ff]" + name + [-];
- break;
- case 5:
- str = "[ffa500]" + name + [-];
- break;
- default:
- str = "";
- break;
- }
- return str;
- }