In my game I am showing a button at top. When the user clicks it, it was supposed to pops up a game over screen. Now this button works fine when I play it in unity or even play it using the File → Build & Run.
But the problem occurs when I just build the game and try playing it using my game.exe file. The button is still there, but when I click the button it does nothing. Btw, the game over screen was supposed to show up after hitting x button on keyboard and that’s not working either.
I am creating the Game Over Screen in OnGUI using GUI functions.
EDIT:
void StopGame()
{
AppendString(PlayerScript.GData);
currentMode = GAME_MODE.STOP;
Time.timeScale = 0;
}
void AppendString(string GameData)
{
TextWriter io;
string File = "data";
if(System.IO.File.Exists(File+".csv"))
{
io = new StreamWriter("Assets/Resources/"+File+".csv");
io.WriteLine(GameData);
io.Close();
return;
}
else
{
System.IO.File.Create(File+".csv");
io = new StreamWriter("Assets/Resources/"+File+".csv");
io.WriteLine(GameData);
io.Close();
return;
}
}
But the Exit(x) button is not working.
Could you post the relevant code?
– thef1chesserAre you getting any error message when running from the Editor?
– raimon.massanetdid you add the game over Scene to build settings?
– Fornoreason1000@thef1chesser i added some more code
– blackcloud1971@raimon.massanet: no there's no error msg @fornoreason1000: game over scene is not a separate scene, may be this will clarify it: i'm making a GUI box with some text and button in it when user clicks Exit(x) button
– blackcloud1971