Hi, I have a problem that is reaaally annoying me.
I have a really simple code that works perfectly fine when I launch it on the editor, but that goes nuts when I Build and Run it. I’ve been trying to find the problem for so long, but I can’t seem to make it work. Here it goes :
public class Menu : MonoBehaviour {
bool inMenu = true;
bool inLobby = false;
void OnGUI(){
if(inMenu){
if(GUI.Button(new Rect(Screen.width-100, 0, 100, 50), “Connect”)){
inLobby = true;
inMenu = false;
}
}else if (inLobby){
GUI.Label(new Rect(Screen.width-100, 0, 100, 50), "Number of players: " + 1);
if(GUI.Button(new Rect(Screen.width-100, 50, 100, 50), “Start Game”)){
Destroy(this);
}
}
}
}
The Code in inMenu works fine, but as soon as I get inLobby in my Build, the inMenu code stays on. Here’s a picture of the problem