[Solved] Script print commands not appearing in console in during play in Unity

Hi all.

Unity version 4.6.9f1
Running on Windows 10 on Razer Blade Pro laptop

Observed:
Screen turns either blue (with camera) or black (when camera is deleted) on play in unity, and no commands show up in the console while working with the NumberWizard.cs script.

Expected:
Was working with it a couple days ago and it worked just fine. I am expecting to see the print commands appear and the updates with up and down arrow keypresses, but nothing appears in the command prompt window.

Steps Taken:
Removed all “void StartGame” and “NextGuess” functions to revert code to the structure when it was last working (the end of Lecture 19, “Using IF to Create Choices”, before 20, “Scope and Context of Variables.”).

Code:
https://gist.github.com/lyndajgerry/f20f4e0dd25ccbf1dafd8b8917a14fac

The Game window turning blue or black on play is perfectly normal, so don’t worry about that. However your code should definitely print to the console. Make sure there is an object in your scene with this script attached as a component. Also make sure your console is visible (it is always possible that it is hidden by another tab), but the prints should still appear in the lower bar of the editor.

Hi Sebastian,

Thanks for the quick response. Yes, I am 100% sure that the console is visible and not hidden by another tab. The prints are not appearing in the editor at all.

I solved the problem by Google Searching “how to attach a script to a object in unity.” I selected “Game Object” from the left panel (on the left side of the playback screen in default display), then “Component” from the top menu, “Scripts”, and “NumberWizard.cs”

However, I do not completely understand how this problem emerged. Can you please clarify?

Sorry, it was my bad for not explaining myself clearly :slightly_smiling_face:

Glad you managed to solve the problem yourself!

Specifically, I would like to know: Why did the script get unattached from the game object, and how can I prevent this in the future?

I hope that question makes sense, thank you Sebastian!

I’m not sure why it got unattached to be honest, maybe you closed Unity without saving the scene? Or you changed the script’s name? Or it could simply be a bug.
Was there still a script component on your GameObject, in the inspector, with no script? By which I mean, did you see this:
Untitled