I have a Main Menu Screen, and a start button to load the first scene. When clicked it works as expected and loads the first scene. However when returning to the main menu via using the pause menu.
The start button is clickable, runs the coroutine used to load the first scene again however Application.LoadLevel(“Gameroom”); does not run this time.
public class StartButton : MonoBehaviour
{
public Texture2D unpressed;
public Texture2D pressed;
public static bool startClicked;
IEnumerator BeginGame()
{
Debug.Log("Coroutine ran");
yield return new WaitForSeconds(1.0F);
Application.LoadLevel("Gameroom");
}
void Start ()
{
startClicked = false;
}
void Update ()
{
if(guiTexture.HitTest(Input.mousePosition))
{
if(Input.GetMouseButtonUp(0))
{
startClicked = true;
guiTexture.texture = pressed;
StartCoroutine("BeginGame");
}
}
}
}
The Debug.Log displays as expected in the console. Any Ideas as to why Application.LoadLevel(“GameRoom”); isn’t running after the scene loads for the second time?
I am scripting in c#.