如何强制符号在文本框中换行

huangapple go评论56阅读模式
英文:

How to force symbols to break line in textbox

问题

我在运行时生成文本,我需要我的文本框不要分隔符号,如"+"或"/"。它会很好地断开单词,但像"+3/+3"这样的文本并不被视为一个完整的单词,所以它会分开。
示例
有没有一种方法可以强制文本框将这些符号视为一个完整的单词?
我在Unity中使用TMPro文本。
谢谢!

英文:

I generate text on runtime and I need my textbox NOT to break symbols such as "+" or "/". It will break the line just fine with words, but text such as "+3/+3" isn't considered a whole word so it breaks.
Example
Any way of forcing the textbox to treat those symbols as a whole word?
I'm using TMPro text in Unity.
Thanks!

答案1

得分: 0

尝试这个。 TMPro支持富文本,而且他们有一个用于此类事情的标签。链接中的示例显示了一个单词,其字母之间有空格,但它没有被分开。这不会成为一般规则,但您可以根据需要控制什么被视为“完整单词”。

富文本有时非常方便。

英文:

Try this. TMPro supports rich text and they have a tag for such a thing. The example in the link shows a word with whitespace between its letters yet it's not broken up. This won't be a general rule, but you can control what is considered a "whole word" on demand.

Rich text is very convenient sometimes.

huangapple
  • 本文由 发表于 2023年2月26日 19:51:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/75571776.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定