Help us understand the problem. What is going on with this article?

[Unity] Debug.Log で出力する文字の色を変えよう

More than 5 years have passed since last update.

Unity の Debug.Log って見づらくないですか?
どうにかこうにかできないかなと思い調べてたら色付けできるみたいですねこれ!
http://docs.unity3d.com/ScriptReference/Debug.Log.html

ってことでそのメモです.

1.png

Debug.Log で出力する文字の色を変える

文字列をタグで囲うと, その情報が反映された状態で
表示されるみたいです.

Debug.Log ("<color=red>Hello, world!</color>");

Unity の Console パネルに赤く Hello, world! と表示されるのが
わかるかと思います.

1.png

GUI の Label とかも同じ方法でいけるみたい

下記のコードを書くと

void OnGUI() {
    GUI.Label (new Rect(10, 10, 100, 100), "<color=red>Hello, world!</color>");
}

こんな感じで表示されます!

2.png

活用例

数値が一定以上にいったらコンソールの色を変えるとかすると
便利かもなぁなんて思いました.

if (this.num < 10) {
    Debug.Log (this.num);
} else {
    Debug.Log ("<color=red>" + this.num + "</color>");
}
phi
Game Programmer. phina.js 作ってます♪
http://phiary.me
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした