I'm working on a project that has a lot of logging messages that pass very fast.
I can use error logs or warning logs but is there any way to log something with different colors so it is easier to find?
Right now, I just use something like this:
Debug.LogError("show missing gold popup accepted");
Answer
Your very first step to answer this question should be to check the Unity documentation, where you'd find a helpful code example that does exactly this:
Debug.Log("
Or if you were looking at the Debug.LogError documentation instead, you'd see:
When the message is a string, rich text markup can be used to add emphasis. See the manual page about rich text for details of the different markup tags available.
And following that link, you'd find the exact syntax for setting a colour:
color
Sets the color of the text according to the parameter value. The color can be specified in the traditional HTML format. #rrggbbaa …where the letters correspond to pairs of hexadecimal digits denoting the red, green, blue and alpha (transparency) values for the color. For example, cyan at full opacity would be specified by color=#00ffffff…
You can specify hexadecimal values in uppercase or lowercase; #FF0000 is equivalent to #ff0000.
We are
colorfully amusedAnother option is to use the name of the color. This is easier to understand but naturally, the range of colors is limited and full opacity is always assumed.
some text The available color names are given in the table below.
So please do get in the habit of reading the documentation first.
This is not the first time I've observed a post of yours that could be answered or improved with a quick check of the documentation or time spent testing in-game. Please take your time and use the full resources available to you, and you'll tend to reach the correct solutions faster than by rushing to post here.
No comments:
Post a Comment