Unity rich text: Getting the most out of text formatting in unity

Text in unity is little under powered. But you can make some good looking UI with the basic settings and unity rich test formatting. Rich text formatting allows you to add HTML tags to unity text , but there are only a limited options that you can add. In this post we will cover how you can make good looking text UI with the options available in unity.

You can add text using the Gameobject>create>other> UI>text option. Once you have added it you will see an text element in the hirarchy. Select the UI gameobject and you can see the options in the inspector window like the one in the image below.

Unity gives you option to change the font , font style ,font size ,alignment. It also has option to wrap text. Material is one option that many people underestimate. You can get a theme based UI with the material option. Unity asset store has lot of UI materials that you can use to get the right looking UI for your game.

Raycast target is used when you want the text to be clickable. Mostly people use buttons for this purpose, but in some scenarios text looks like a best fit. Don’t enable this option if you don’t want your text to work as a button. Raycast target is enabled be default when you add it to your hirarchy, don’t forget to disable it. Many text with raycast targets can add to performance issues.

Unity Rich Text

You can see a check box in the above image that says rich text. Normally if you enable it you wont see any difference in the text you have added. What it does is , it enables the markup text formatting options. Markup text is similar to HTML formating. You can do a lot of innovative things with this. Lets see what are the options available and how to use them.

1.BOLD, Italics and Size

You can use “<b>” to make some characters bold., “<I>” is used for italics and “<size>” is used for font size.

2. MAterial ,Color and quad

HTML tags <color>,<material>,<quad> is used to specify the color ,material and quad for the text.

The main reason to use rich text formatting is to get different styles for words in a single sentence. Lets see an example for better understanding.

Lets take the sentence ” Unity Rich Text is really useful” and apply different style to different word .Enter this in the text box to test ” <b>Unity</b> <I> Rich</I> text is <color=”blue”>really<\color> useful”,

Have fun formatting text and come up with your own innovative text UI. You can check out the best UI assets for more formating option.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.