Java code not working. LOST PROJECT

Okay so I was just making a game i spent alot of time on it and saddy i deleted it on accident so I was trying to type my long script over again and it is not working.
here is the code:

var Glock17   : GameObject;

var Glock17Aim	: GameObject;

private var ShowMenu = false;

private var Rank = 0;
private var Kills = 0;
private var EXP = 0;
private var Wave = 0;

function Start () {
	Glock17.SetActive(true);
	Glock17Aim.SetActive(false);
}

function Update () {

 	if(Input.GetMouseButtonDown(1)) {
	Glock17.SetActive(false);
	Glock17Aim.SetActive(true);
	}
	if(Input.GetMouseButtonUp(1)) {
	Glock17.SetActive(true);
	Glock17Aim.SetActive(false);
	}
	
	ShowMenu = true;
	if(ShowMenu == false) {
	if(Input.GetKeyDown ("space")) {
		ShowMenu = true;
	}
	}
	if(ShowMenu == true) {
	if(Input.GetKeyUp ("space")) {
		ShowMenu = false;
	}
	}
}
function OnGUI() {
	
	if(ShowMenu == true) {
		GUI.Box (Rect(0, 0, 640, 480), "Pop Up" );
		GUI.Box (Rect(0, 0, 640, 480), "Pop Up" );

		GUI.Box (Rect(0, 0, 150, 480), "Stats" );
		GUI.Box (Rect(0, 0, 150, 480), "Stats" );
		
		GUI.Box (Rect(200, 0, 130, 130), "" );
		GUI.Label (Rect(0, 0, 130, 130), "Wave:" + Wave );
	
	
	}
}

Some of the GUI stuff dont work. and the vars dont. Sigh
well thanks :frowning:

Unity doesn't use Java. If you're trying to say "Javascript", that's a different language entirely; Java can't be used as shorthand for it. Sorry to be picky, but programmers should know this.

Some of your GUI lines are duplicated. What specific problem are you having?

You cannot display Wave as an int (or float, who knows what Wave is with dynamic typecasting) in GUI, you need to convert it to a string : GUI.Label (Rect(0, 0, 130, 130), "Wave:" + Wave.ToString() ); this is what I gleaned from Some of the GUI stuff dont work. and the vars dont.

Besides clearing the confusion of Java and Javascript, you may also consider restyle your code with better indentation. :D

1 Answer

1

Most of your GUI Scripts are covering each other, like covering a piece of paper with another. You can use GUILayout, which organizes your GUI automatically. This is good because you will on have these overlapping errors.

Okay will try that and I am fine now it turns out I had the Exit unity and go back into it to fix it.

Dear Clonkex, your solutions are voted most, can you rewrite it in a simpler paragram please? Please take a chance to look at my explanations also.