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

Failed to remove SceneContext from SceneContextRegistry #61

Open
bilalakil opened this issue Nov 11, 2022 · 2 comments
Open

Failed to remove SceneContext from SceneContextRegistry #61

bilalakil opened this issue Nov 11, 2022 · 2 comments

Comments

@bilalakil
Copy link

Describe the bug
I'm getting this warning message in the console for no significant reason: "Failed to remove SceneContext from SceneContextRegistry"

To Reproduce
Add this static class to a project to unload a scene in case when the projected is started from the wrong scene:

public static class StartSceneController 
{
    [RuntimeInitializeOnLoadMethod]
    private static void onAppLoaded()
    {
        Scene scene = SceneManager.GetActiveScene();

        if (scene.buildIndex != 0)
                SceneManager.LoadScene(0);
    }
}

Expected behavior
No warnings in the console.

Extenject and Unity info (please complete the following information):

Zenject version: 9.3.1
Unity version: 2021.3.12f1
Project's scripting backend [e.g. Mono/IL2CPP]: mono
@wayheart
Copy link

public async UniTaskVoid LoadSceneAsync(string nextScene, Action onLoaded = null)
{
    if (SceneManager.GetActiveScene().name == nextScene)
    {
        onLoaded?.Invoke();
        return;
    }

    AsyncOperation asyncOperation = SceneManager.LoadSceneAsync(nextScene);

    asyncOperation.completed += _ => onLoaded?.Invoke();

    await UniTask.WaitUntil(() => asyncOperation.isDone);
}

I have the same problem.

@wayheart
Copy link

The problem was that I called the scene change in Awake, changed it to Start. I realized this after reading the Extenject documentation

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

2 participants