How to allow rich text for TextField?

I want to use a readonly TextField so I can highlight and copy things. For example, I’m dumping server error logs here and want to nicely parse it. Eg: <color=red><b>Error:</b></color> so it pops out.

As I’m logging things, I want people to be able to select some text to copy. For example, copy errors to paste to colleagues or Google. I literally want the same thing as the Console tab, which is essentially a readonly TextField with rich text support.

How come there’s no rich text option for TextField since it can be readonly with the Console tab being the perfect real-use common scenario for such a feat? Is there a secret prop, perhaps?

Currently using Unity 2022.3.24 LTS (and can only stay within LTS)

Hello. You can’t do it from the UI Builder, but you can do it from code. You can enable the rich text flag for the text input:

        var textInput = myTextField.Q("unity-text-input");
        var textElement = textInput.Q<TextElement>();

        textElement.enableRichText = true;
1 Like

This is in the lts? I couldn’t find richText under the element name when I tried looking around for code enables

It’s right there in the docs: https://docs.unity3d.com/2022.3/Documentation/ScriptReference/UIElements.TextElement.html

1 Like

Ah, then if a mod reads this, feel free to close the thread. No idea why my intellisense wasn’t showing that - maybe I typod it. Thanks