I’ve been having some problems getting the name display to work, turns out I just needed some curly braces in there.
However now when I load my main menu the scene is skipping straight into my main level scene without the ‘start’ button being pressed. The scene loads for a couple of seconds then skips. This aspect of the scene was working perfectly until I input the new code, so I have a feeling I’ve put the new script in the wrong place.
if (GUI.Button (new Rect(Screen.width/2-buttonWidth/2,
buttonyPosition,buttonWidth,buttonHeight), "Start"))
{
GameObject gameData=GameObject.Find("GameData");
if (gameData!=null)
{
GameDataScript gameDataScript=gameData.GetComponent<GameDataScript>();
gameDataScript.playerName=nameText;
}
}
{
//load the level
StartCoroutine(PlayButtonClick());
Application.LoadLevel("PhysicsLab");
}
The new code causing the problem is the part about GameObjects.
Any help would be greatly appreciated!