- Home /
game lost functionality after build
I am trying to make a 2D top down shooter using c# but when I build my game I lose some functionality which I do have if I run the game in the editor.
The following script is something that will do some things if the player choose to go to the next level after one is complete.
These three method calls will not execure after being built but they will in the editor:
Time.timeScale = 0;
if (Input.GetKeyDown("space")) // go to next level
{
Debug.Log("Space pressed");
this.GetComponent<CharacterSelect>().LoadCharacter();
this.GetComponent<PlayerGUI>().SetUIValues();
this.GetComponent<GlobaGUIHandler>().SetPlayModeGUI();
Debug.Log("Loading next level");
Application.LoadLevel(Application.loadedLevel + 1);
Debug.Log("next level loaded");
}
LoadCharacter() does have a debug.log in its first line which I never get to after building. What am I doing wrong here?
$$anonymous$$ight not be related,but I've never seen anyone call Start() on a script directly - I would encapsulate that code in another function that is called from Start(), and also called when you complete a level.
Ok I have edited the question after a few more hours of fighting this bug.
Did you say that it works in the editor but not in the build? And why did you use Time.timeScale = 0;
? Another question, where do you put these code of yours? Start()
? OnGui()
? Update()
?
This is inside OnGUI()
and that is why I have Time.timeScale = 0;
, I want the actual game to pause while I have some victory/game over GUI screen.
Answer by Gatsua · Aug 18, 2014 at 06:38 AM
This was caused by:
Input.GetKeyDown("space")
Because the keypress was detected from the last scene after building but not when running the game in Unity.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Unity build Complete size does not match app size 0 Answers
Distribute terrain in zones 3 Answers
I making a game for windows 8 1 Answer
New C# scripts fail to build 2 Answers