Question by
popernennins · Feb 22, 2016 at 09:45 AM ·
scene-loadingdelay
Loading a scene after a set delay
I'm trying to have a delay set so after I press the GUI button I've set up, it waits for 3 seconds and then changes scenes. I've tried a bunch of stuff, but none of it has worked, probably because it is in a group of commands.
if (GUI.Button (new Rect(Screen.width * .17f, Screen.height * .38f, Screen.width * .38f, Screen.height * .39f),Invisible, "")){
print ("clicked Play Game");
Application.LoadLevel("firstareas");
Comment
as i see you are loading the scene immediately when clicking the button where is the wait time this should work :
if (GUI.Button (new Rect(Screen.width * .17f, Screen.height * .38f, Screen.width * .38f, Screen.height * .39f),Invisible, ""))
{
print ("clicked Play Game");
StartCoroutine (LoadScene());
}
IEnumerator LoadScene()
{
yield return new WaitForSeconds (3);
Application.LoadLevel("firstareas"); }
note Application.LoadLevel is not working with the new unity what version do you use !