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

24,004

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.

enter image description here

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

enter image description here 3.The NumberWizard script is not enabled. Enable the script.

enter image description here

4.The log toggle is not checked.

enter image description here

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 enter image description here

Share:
24,004
Ahmed Abbas
Author by

Ahmed Abbas

Updated on July 05, 2022

Comments

  • Ahmed Abbas
    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. enter image description here

  • Programmer
    Programmer over 7 years
    No. This is Unity3D
  • mindOfAi
    mindOfAi over 7 years
    If print and Debug.Log don't work, probably, your code isn't getting called.
  • Ahmed Abbas
    Ahmed Abbas over 7 years
    Debug.Log and Print both are not printing on Console. @mindOfAi
  • Ahmed Abbas
    Ahmed Abbas over 7 years
    System.Console.WriteLine("your string here"); is also not working @Svek
  • mindOfAi
    mindOfAi over 7 years
    Can you add a breakpoint on your Start() method? Make sure it's getting called.
  • Ahmed Abbas
    Ahmed Abbas over 7 years
    and i am pressing Play button.Nothing Happens
  • Ahmed Abbas
    Ahmed Abbas over 7 years
    You Are life savior.. The third one works . God bless you
  • Ahmed Abbas
    Ahmed Abbas over 7 years
    @Programmer solution works... script is not attached to the object
  • Ahmed Abbas
    Ahmed Abbas over 7 years
    Programmer solution works... script is not attached to the object
  • mindOfAi
    mindOfAi over 7 years
    Yeah, I stated it in my answer that you should make sure the script's attached.
  • codejockie
    codejockie over 6 years
    Thanks a lot, it worked. I had to delete the script I created and used the add component to create a new script.
  • A__
    A__ over 4 years
    I'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
    xjcl about 3 years
    Which log file? Player.log? Can't find it there either