Unity Tips – Rich Text in the Console

As Unity supports Rich Text tags, you use them in your Debug.Log methods in order to liven up your Console window and put emphasis on important Debug lines. Whilst some Rich Text tags will be more useful than others in this context, some helpful examples would be Color, Bold, Italics and maybe even Size, depending on how you have your Console setup.

An example of Rich Text being used in the Console.

Here are some examples of Rich Text tags in use in code. A good idea would be to write extension methods for commonly used debug lines so that you don’t have to keep writing out the same tags.

Debug.Log($"This object's name is <b><color=white>{gameObject.name}</color></b>!");

Debug.Log("<color=green><b>Everything has gone okay!</b></color> <i><size=8>Hooray</size></i>");

Debug.LogError("<color=red><b>[ERROR]</b></color> - Something has gone wrong.");

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s