Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Kerihobo · Jan 22, 2015 at 12:42 AM · colordebuglog

debug.log with color (variable)????????

After looking at this reference page: http://docs.unity3d.com/ScriptReference/Debug.Log.html

I have this variable at the top of my code

 private Color[] color_debug_log = new Color[]{    Color.red,
                                                     Color.green,
                                                     Color.blue,
                                                     Color.magenta};

when I debug log like this however

 Debug.Log ("<color=color_debug_log[1]>Player " + 1 + " joined the game");

it gives me default color, instead of green. Is it not possible to use color variable in these cases? the fact that the tag must be inside string is something I can see being a problem when trying to access a variable.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image freshingrain · Nov 06, 2015 at 07:43 AM -1
Share

You can read this document: http://docs.unity3d.com/$$anonymous$$anual/StyledText.html

It includes all styles which could be used in Debug.Log()

5 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Eric5h5 · Jan 22, 2015 at 12:54 AM

You can use a variable, but naturally it has to be outside the string; otherwise Unity has no idea it's a variable. Also the variable would have to be a string, not a Color, because you're outputting strings where the color is parsed from the string.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Kerihobo · Jan 22, 2015 at 01:15 AM 0
Share

Thanks mate! That worked! I stored an array of strings ins$$anonymous$$d of colours, and then i concatenated it in to the colour's position in string. cheers :D

avatar image
3

Answer by ismakefire · Jun 08, 2017 at 03:50 PM

A code sample for easy reference.

 Color color = color_debug_log[1];
 string message = "Player " + 1 + " joined the game";
 
 Debug.Log (string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(color.r * 255f), (byte)(color.g * 255f), (byte)(color.b * 255f), message));
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
2

Answer by Seyed_Morteza_Kamaly · Oct 18, 2019 at 10:31 AM

KamaliDebug

https://github.com/smkplus/KamaliDebug

Easy way to Debug Colorful Texts in Unity Console

image

Variables

image

Syntax

(Text or Emoji):Color:TextStyle;

Font Color

DebugX.Log("Hello world:green;");

image

Font Style

DebugX.Log("Hello:b; World:i;");

image

Emoji

DebugX.Log("love:red:b; love:red:b; love:red:b;");

image

Complex

DebugX.Log("Hello:yellow:b; world:red:b;");

image

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
2

Answer by bart42 · Jun 21, 2021 at 11:11 AM

You can do

 print($"<color=#00FF00>All files processed...</color>");
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by onetimepad · Apr 23 at 12:39 PM

 public static string Colorize(string text, string color, bool bold){
     return
     "<color="+color+">"+
     (bold?"<b>":"")+
     text+
     (bold?"</b>":"")+
     "</color>";
 }



Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

35 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is there a way to set Unity to write message log when the calculation has Infinity or NaN? 3 Answers

Have my debug log saved to a .log file in build. 2 Answers

Debug.Log Override? 3 Answers

Reading the profiler log 0 Answers

Debug.Log is causing an Assert 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges