Error CS0103: The name 'print' does not exist in the current context

Hi,

When I enter the code from the lecture:

void Start () {
print (“Welcome to Number Wizard!”);
print (“Pick a number in your head but don’t tell me”);
}

Nothing displays to the console when I run the program in Unity. When I place the pointer over print, I get a popup that says “error CS0103: The name ‘print’ does not exist in the current context”.

I have the script attached to a game object that is inside the scene.
I am fairly certain my code looks like the code in the lecture.

Does anyone know if there is some setting I have to set that I may have missed? Any other suggestions?

Hello @Douglas_Atkinson,

Could you paste up the full script please and we’ll take a look :slight_smile:

Here is the full script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NumberWizard : MonoBehaviour {

	// Use this for initialization
	void Start () {
		print ("Welcome to Number Wizard!");
		print ("Pick a number in your head but don't tell me");
	}
	
	// Update is called once per frame
	void Update () {
		
	}
}

As far as I can tell it is the same as the one in the lecture except for the addition of the using Systems.Collections.Generic;

Doug

Can you take a screenshot? Also, when you hit the triangle play button in Mono develop, can you take a screenshot of that? Most likely you are missing a single character, and your whole problem is a typo.

Hi Doug,

Other users who have experienced similar issues like this have found closing both MonoDevelop and Unity and re-opening can clear the issue. Try the same if you are using Visual Studio.

Your script looks fine.

Closed both MonoDevelop and Unity and restarted. Same problem.

If you want to zip up the project I will have a look at this end for you Doug. You can upload the zip file within your post.

Just a thought, what happens if you comment out your print () statement lines? Will it run in Unity then without error? Admittedly it wont do anything.

1 Like

I think that the problem may be that I do not have .net framework 3.5 installed on my computer. I have a Windows 10 machine and am having difficulties getting .net framework 3.5 installed. I will keep working on it and once I eventually get it installed, I will see if it makes any difference.

If you have a look inside MonoDevelop, goto project options, and then under build, click on general - there should be a drop down menu with a select assembly, you could try setting it to mono / .Net 2.0 and see of the code runs without issue.

Then grab the more recent framework after.

I am having the same issue and I have a Mac. Tried the last solution but “project option” is block and I am not allowed to click on it. Any other solution?

Do you have any .NET framework installed?
I have .NET framework 4.5 on my Windows 10 machine and not seeing this same issue. I don’t have 3.5 at all on my machine and shouldn’t be a requirement if you have a newer version installed.

Hello Douglas,

It’s been a while since you posted this question, so I want to follow up and ask if you were able to resolve the issue? If not, I’d be glad to help further. Please let me know.

Happy Coding :slight_smile:

1 Like

I am not sure if this is still an issue for some but thought I would mention this after running into the error myself and spending quite awhile googling too, as @Rob mentioned try leaving a space between print and () because it worked for me.

To anyone who stumbled upon this thread:
Does your class inherit from MonoBehaviour?
If not, use Debug.Log(""); instead.

1 Like

Privacy & Terms