2
\$\begingroup\$

I'm currently writing a debug script and would like to add colors to certain parts of the debug messages. Reading the unity docs lead me to believe that I can use the Rich text formatting. Like it is explained here. I'm using the Debug.LogForamt().

Logs a formatted message to the Unity Console.

For formatting details, see the MSDN documentation on Composite Formatting. Rich text markup can be used to add emphasis.

This is from the unity docs. My code looks like this :

Debug.LogFormat("Status of some gameObject is : <color = red>{0}</color>" +
"Status of another gameObjcet is: <color = red>{1}</color>",
gameObject1.activeInHierarchy,gameObject2.activeInHierarchy);

This just outpust the strings as plain text. What am I doing wrong ?

\$\endgroup\$
2

1 Answer 1

1
\$\begingroup\$

Have you tried to remove the extra spaces and / or set the color in hex format?

Debug.LogFormat("Status of some gameObject is : <color=#ff0000ff>{0}</color>" + "Status of another gameObjcet is: <color=#ff0000ff>{1}</color>", gameObject1.activeInHierarchy,gameObject2.activeInHierarchy);
\$\endgroup\$
2
  • \$\begingroup\$ Yes! Both tries yielded the same result. \$\endgroup\$
    – Uri Popov
    Commented Feb 13, 2017 at 9:42
  • 3
    \$\begingroup\$ restarting unity fixed it X_X. As always. \$\endgroup\$
    – Uri Popov
    Commented Feb 13, 2017 at 9:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .