NGUI——让UILabel可以显示彩色文字

作者:追风剑情 发布于:2018-6-22 17:31 分类:NGUI

一、修改UILabel.cs
1、增加个变量
public List<Color> vertexColors = null;

2、修改OnFill()方法

22222.png


二、修改NGUIText.cs
1、增加一个变量
static public List<Color> vertexColors = null;
2、修改Print()方法
33333.png


这是一组测试数据

//一组测试数据
List<Color> vertexColors = new List<Color>(){
	new Color(254f/255f, 91f/255f, 123f/255f),
	new Color(255f/255f, 87f/255f, 113f/255f),
	new Color(184f/255f, 117f/255f, 124f/255f),
	new Color(184f/255f, 117f/255f, 124f/255f),

	new Color(204f/255f, 137f/255f, 128f/255f),
	new Color(255f/255f, 97f/255f, 92f/255f),
	new Color(246f/255f, 168f/255f, 104f/255f),
	new Color(193f/255f, 162f/255f, 144f/255f),

	new Color(246f/255f, 168f/255f, 104f/255f),
	new Color(246f/255f, 168f/255f, 104f/255f),
	new Color(255f/255f, 83f/255f, 166f/255f),
	new Color(255f/255f, 165f/255f, 232f/255f),

	new Color(237f/255f, 167f/255f, 227f/255f),
	new Color(255f/255f, 135f/255f, 208f/255f),
	new Color(253f/255f, 83f/255f, 253f/255f),
	new Color(237f/255f, 167f/255f, 227f/255f),

	new Color(237f/255f, 167f/255f, 227f/255f),
	new Color(255f/255f, 135f/255f, 208f/255f),
	new Color(132f/255f, 7f/255f, 112f/255f),
	new Color(159f/255f, 46f/255f, 131f/255f)
};

使用方式

//赋值给UILabel
uilabel.vertexColors = vertexColors;
uilabel.applyGradient = true;//开启渐变效果

游戏中的测试效果截图

1111111.png

标签: NGUI

Powered by emlog  蜀ICP备18021003号   sitemap

川公网安备 51019002001593号