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
\$\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
    Feb 13 '17 at 9:42
  • 2
    \$\begingroup\$ restarting unity fixed it X_X. As always. \$\endgroup\$
    – Uri Popov
    Feb 13 '17 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.