I have three lines of text displaying the score, player lives, and player power in my game. In the editor, it plays perfectly fine, but when I build the game, the moment one of the values is updated, it looks like there are five or six numbers being displayed at the same time.
This is what it looks like:
And this is the code controlling the GUI. It’s attached to the camera for that level.
void OnGUI() {
float startingPosition = Screen.width - (Screen.width / 4);
GUILayout.BeginArea(new Rect(startingPosition, 0, Screen.width / 4, Screen.height));
GUILayout.BeginHorizontal();
GUILayout.BeginVertical();
GUILayout.Label("Score", customSidebar);
GUILayout.Label("Lives", customSidebar);
GUILayout.Label("Power", customSidebar);
GUILayout.EndVertical();
GUILayout.BeginVertical();
GUILayout.Label(PlayerPrefs.GetInt("score") + "", customSidebar);
GUILayout.Label(PlayerPrefs.GetInt("playerLives") + "", customSidebar);
GUILayout.Label(PlayerPrefs.GetInt("playerPower") + "", customSidebar);
GUILayout.EndVertical();
GUILayout.EndHorizontal();
if (GUILayout.Button("Main Menu", GUILayout.Height(50)))
Application.LoadLevel(0);
GUILayout.EndArea();
It works fine in the editor, is there any reason why it would work there and not work when I build the game?