c# - 如何在 Unity 中仅更改单个字母的颜色?
问题描述
我正在尝试制作纸牌游戏,我想显示一个描述纸牌的文字。说:“对目标造成 4 点伤害。” 我希望这个“4”部分的颜色不同。我怎样才能做到这一点?
public string formerPartOfText = "Deal ";
public int damage = 4;
public string rearerPartOfText = " damages to the target.";
public string finalText = formerPartOfText + damage.ToString + rearerPartOfText;
print(finalText);
我将字符串分成两部分,因为我希望能够更改可变损坏
解决方案
特别是颜色标签:
var damage = 4;
var str = $"Deal <color=#ff0000ff>{ damage }</color> damage to the target";
推荐阅读
- php - HTML lang 属性在 mPDF 中不起作用
- python - 如何在 Pandas to_datetime 中显示小时?
- r - 如何更改列名以符合 mlr3 的命名约定
- mysql - MySQL 加入 JSON 数组
- elasticsearch - curl: (7) 无法连接到 localhost 端口 9300: Connexion refusée
- javascript - 赛普拉斯如何获取文本长度
- bash - BASH_REMATCH 在 Bash 5.1 中不是只读的有什么用?
- meson-build - 介子:如何在构建目标之前执行 run_command?
- java - 如何创建具有 1 和 0 的 Java 2D 数组?
- php - Doctrine ManyToOne 关系 - 在“设置”时自动删除