- Home /
Scenes automatically skip without initialisation.
Hi there. I've been following the space shooter tutorials in C#. I've already added my scenes, and my "Start" button. For some reason when I run the scene, it automatically skips over to the next scene without the button being pressed. My coding seems right. Are there perhaps settings in Unity itself which would cause this?
using UnityEngine; using System.Collections;
public class MainMenu : MonoBehaviour { #region Fields private string instructionText = "Instructions:\nPress Left and Right Arrows to move.\nPress Spacebar to fire.";
private int buttonWidth = 200;
private int buttonHeight = 50;
#endregion
#region Properties
#endregion
#region Functions
void OnGUI()
{
GUI.Label(new Rect(10, 10, 250, 200), instructionText);
if (GUI.Button(new Rect(Screen.width / 2 - buttonWidth / 2,
Screen.height / 2 - buttonHeight / 2, buttonWidth, buttonHeight), "Start Game")) ;
{
Application.LoadLevel(1);
}
}
#endregion
}
Answer by JohnnySunshine · Aug 13, 2013 at 11:13 AM
Remove the semicolon at the end of the button line ;)
Answer by Grape Wizard · Aug 13, 2013 at 11:59 AM
Never mind. I figured out my own problem: The semi-colon after the IF statement had to be removed.