Quantcast
Viewing all articles
Browse latest Browse all 2891

How to fix error CS0103 Cannot implicitly covert type 'bool' to 'string'

I have a question about Unity. I have written a script but it doesn't work. I'm trying to allow the player to enter a name and on pressing Enter the text will change and show "Hello +PlayerName" I have no idea how to fix the error error CS0103 The name `Submit' does not exist in the current context. Please explain string PlayerName = "Player1"; string Submit = false; void Update() { if(Input.GetKeyDown("enter")) { Submit = true; } } void OnGUI () { if (Submit) { GUI.Label (Rect (10, 10, 100, 30), "Hello " + PlayerName); } else { GUI.Label (Rect (10, 10, 100, 30), "Enter Name:"); PlayerName = GUI.TextField (Rect (90, 10, 200, 25), PlayerName, 40); } } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles