简体   繁体   中英

Print/Debug.Log is not showing output on Unity Console

I am trying to print a simple statement using C# on Unity Console but i don't know why it is not printing. 在此处输入图片说明

If print does not work, Debug.Log will not work either so that's not the problem.

These are the possible reasons why print is not showing in the console:

1 .Script is not attached to a GameObject.

在此处输入图片说明

2 .The GameObject the script is attached to is not Active. Activate it from the Editor.

在此处输入图片说明 3 .The NumberWizard script is not enabled. Enable the script.

在此处输入图片说明

4 .The log toggle is not checked.

在此处输入图片说明

From your screenshot, both Debug, Warning and Error messages are enabled, so we can exclude what's in 4.

Pressing "Play"

According to this link , print() or Debug.Log , only will work with the following conditions

It seems that the key piece of information I was missing was that Debug.Log writes to the console only when you run the game from within unity by pressing the "play" button above the game view.

I was running my game by pressing Ctrl-B, or pressing "Build & Run" in the Build Settings window. In that case, it will only output to the log file

So you have to hit the play button above the game view, not by using the "Build & Run".


Check your filters

According to this link , you should also check your filters在此处输入图片说明

Have you tried using Debug.Log ? Also, you can also use these for specificity: Debug.LogWarning and Debug.LogError . Also, make sure this script is attached.

Eg Debug.Log("Started");

Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM