更改UI文本元素颜色的一部分 [英] Change a part of a UI text element's color

查看:159
本文介绍了更改UI文本元素颜色的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,如果我在画布中有一个游戏对象,并且想在运行时更改一个单词的颜色,或者只是将颜色插入显示的字符串中,我该怎么做? C#和团结,谢谢.

So, if I have a game object in my canvas and I want to change one word's color at runtime, or simply insert a color into the string that displays, how would I do that? C# and unity, thanks.

推荐答案

使用富文本更改特定单词的颜色.

Use Rich Text to change the color of specific words.

只需将以下行:<color=yellow>Hello,</color> World!添加到Inspector中的"UIText"组件.不管"UIText"组件中设置的颜色如何,这都会更改标签内单词的颜色.

Just add the following line: <color=yellow>Hello,</color> World! to your 'UIText' component in Inspector. This will change the color of the word inside the tags regardless of the color set in 'UIText' component.

这篇关于更改UI文本元素颜色的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆