LoginSignup
26
18

More than 3 years have passed since last update.

UnityのDebug.Logの上手な使い方

Last updated at Posted at 2018-02-23

UnityプログラミングではDebug.Logを上手に使おう

プログラムが今、どんな値、どんな状態で実行されているのかリアルタイムで確認するのは開発時間の大幅な短縮になります。その日の飲み会に参加できるかできないかここで決まってくるかも知れません。
チーム製作では出しすぎて人の迷惑にならないようにしないといけませんが、バンバン活用しましょう。

基本的な使い方

文字列をそのまま出す

Debug.Log("(・∀・)イイ!!");

スクリーンショット 2018-02-24 0.05.07.png

文字列と変数を組み合わせて出す

string message = "(・∀・)イイ!!";
Debug.Log("message = " + message);

スクリーンショット 2018-02-24 0.06.59.png

intなどの変数も可。

文字列に色をつけて出す

Debug.Log("<color=red>(・∀・)イイ!!</color>");

スクリーンショット 2018-02-24 0.08.46.png

警告やエラーとして出す

Debug.LogWarning("(・∀・)イイ!!");

スクリーンショット 2018-02-24 0.09.51.png

Debug.LogError("(・A・)イクナイ!!");

スクリーンショット 2018-02-24 0.11.33.png

LogErrorはエラー扱いなので、ログウィンドウのErrorPauseをONにしてPauseさせることもできる。

26
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
18