1
\$\begingroup\$

I have tried using IEnumerator and Invoke("method",delay_in_seconds). My first scene is just an image with my studio name on it. I have script that will load the next scene ("Main Menu") 3 seconds after the first scene is loaded. For this, I tried using IEnumerator and Invoke with 3 seconds delay before calling Application.LoadLevel.

However, on the device, game is launched, unity splash screen is displayed and "Main Menu" scene appears. it looks like the image scene loads while unity splash screen is displayed and by the time unity screen is completed, the image scene has done executing.

Is there any way to ensure a scene stays on screen before loading the next scene? I could add a button that player should tap to start game. But I don't want to do that.

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

Create your own timer, and attach it to the scene that is doing the image presentation. This is something that is very simple to do.

float delay = 3;


public Update()
{
    delay -= Time.deltaTime;
    if (delay <= 0)
        LoadLevel("NextLevelToLoad");
}

EDIT

Apparently mobile runs the Update() of the first loaded scene while the splash is running? I haven't personally confirmed this, but it is plausible.

If that is the case, possibly try tapping into OnPreRender to initiate your timer.

Code would be:

float delay = 3;
bool timerEnabled;

public Update()
{
    if (timerEnabled)
    {
        delay -= Time.deltaTime;
        if (delay <= 0)
            LoadLevel("NextLevelToLoad");
    }
}

void OnPreRender()
{
    timerEnabled = true;
}
\$\endgroup\$
6
  • \$\begingroup\$ Did not work. Same issue. Image scene finishes loading while Unity splash screen is displayed. \$\endgroup\$
    – SanSolo
    Jul 24, 2015 at 15:16
  • 1
    \$\begingroup\$ That is pretty weird, your scene shouldn't be loaded until after the splash screen is displayed. In fact, the script in your starting scene will only fire off the Start() function once the splash is done. \$\endgroup\$
    – jgallant
    Jul 24, 2015 at 15:52
  • \$\begingroup\$ May be it's a bug. I tried an alternative. Used two empty game objects with colliders. Made one rigidbody. The rigidbody is positioned to fall on the static. Next scene would be loaded on collision. Even this fired off and I see Main Menu instead of the image scene. \$\endgroup\$
    – SanSolo
    Jul 24, 2015 at 15:57
  • \$\begingroup\$ Is it possible there is another script that is loading the level without delay somewhere? \$\endgroup\$
    – jgallant
    Jul 24, 2015 at 15:59
  • 1
    \$\begingroup\$ I haven't tested this myself, so you may be right, this could be the default behaviour. Possibly try the code I added to the answer. \$\endgroup\$
    – jgallant
    Jul 24, 2015 at 16:26
0
\$\begingroup\$

It looks like there's a bug in Unity. I added another blank screen that would just load my image scene after 3 seconds.The blank scene doesn't show up, but my image scene is displayed.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .