Print/Debug.Log is not showing output on Unity Console
Solution 1
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.
Solution 2
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
Ahmed Abbas
Updated on July 05, 2022Comments
-
Ahmed Abbas almost 2 years
I am trying to print a simple statement using C# on Unity Console but i don't know why it is not printing.
-
Programmer over 7 yearsNo. This is Unity3D
-
mindOfAi over 7 yearsIf print and Debug.Log don't work, probably, your code isn't getting called.
-
Ahmed Abbas over 7 yearsDebug.Log and Print both are not printing on Console. @mindOfAi
-
Ahmed Abbas over 7 yearsSystem.Console.WriteLine("your string here"); is also not working @Svek
-
mindOfAi over 7 yearsCan you add a breakpoint on your
Start()
method? Make sure it's getting called. -
Ahmed Abbas over 7 yearsand i am pressing Play button.Nothing Happens
-
Ahmed Abbas over 7 yearsYou Are life savior.. The third one works . God bless you
-
Ahmed Abbas over 7 years@Programmer solution works... script is not attached to the object
-
Ahmed Abbas over 7 yearsProgrammer solution works... script is not attached to the object
-
mindOfAi over 7 yearsYeah, I stated it in my answer that you should make sure the script's attached.
-
codejockie over 6 yearsThanks a lot, it worked. I had to delete the script I created and used the add component to create a new script.
-
A__ over 4 yearsI'm in build
2019.2.17f1
on Win10 Pro and saw that my log toggle (in your step 4) was accumulating messages as the number indicating how many messages are present was increasing, but they were not actually displaying in the console. The same messages would successfully display in my custom in-game console. Restarting Unity fixed the issue. I might report this as a bug to Unity later if I have time, but just an FYI for posterity -
xjcl about 3 yearsWhich log file? Player.log? Can't find it there either