[SOLVED]Issues with tying the number the computer picks to UI

So, I am not totally sure what I am doing wrong here. I have followed everything along with the course, but I am missing something somewhere. Let me start from the beginning.

I created an Empty to hold the NumberWizard script, and then I set went to “Add Component” and added the NumberWizard script. At that point, that was all I could do.

Next, I followed along and put that I was using UnityEngine.UI, declared my MaxGuessesAllowed variable as well as set it to 10.

I took off all the code referring to key presses since I was going to be using buttons.

I created the GuessHigher, GuessLower, and NextGuess bits. I then followed what I thought was exactly what I was being taught, but I think I missed something because in the lesson, after the script is right, when I go back into Unity and refresh the assets, I am supposed to be able to fill in the Text area in the scripts portion of the inspector, but that area is not available to me.

I will post my code below. Please help! I am at a loss!

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class NumberWizard : MonoBehaviour {

int max;
int min;
int guess;
int MaxGuessesAllowed = 10;

public Text text;
// Use this for initialization
void Start () {

StartGame ();


void StartGame() {
	max = 1000;
	min = 1;
	guess = 500;
	max = max +1;


public void GuessHigher(){

	max = guess;
	NextGuess ();


public void GuessLower(){

	max = guess;
	NextGuess ();


 void NextGuess() {

	guess = (max + min) / 2;
	text.text = guess.ToString();
	MaxGuessesAllowed = MaxGuessesAllowed-1;
		Application.LoadLevel ("Win");


// Update is called once per frame



Sorry to waste anyone who may have read that post in the last 5 minute’s time. I found the error. I went to run it just see what would happen, and it turns out it was a compiler error, so I went through and did my standard "look for missing semicolons or braces, and I found that I had an extra brace on the end. Took that out, and problem solved.

Guess we know what I need to be working on!

1 Like

Gotta love the curly braces and semi-colons :slight_smile:

Take some credit for spotting and resolving the issue yourself :slight_smile:

Privacy & Terms