Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StartCoroutine with LoadSceneAsync in _Enter states loading instantly #33

Open
st4rdog opened this issue Dec 14, 2018 · 0 comments
Open

Comments

@st4rdog
Copy link

st4rdog commented Dec 14, 2018

For some reason, this code will load the level instantly on _Enter, instead of waiting until the MainMenu_Enter.

private AsyncOperation load = new AsyncOperation();

void Intro_Enter()
{
    // Preload Level
    StartCoroutine(PreLoadLevel());
}

void Intro_Update()
{
    _introTimer += Time.deltaTime;

    if (_introTimer > _introLength)
        _fsm.ChangeState(States.MainMenu);
}

void MainMenu_Enter()
{
    // Show preloaded level
    load.allowSceneActivation = true;
}

IEnumerator PreLoadLevel()
{
    load = SceneManager.LoadSceneAsync("scene", LoadSceneMode.Additive);
    load.allowSceneActivation = false;
    yield return null;
}

Moving the StartCoroutine out into the Start function will work as expected...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant