Skip to content

Unable to link all scene datas to loaded scenes. Linked 0/1 #40

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

Closed
VirtualMaestro opened this issue Jul 31, 2024 · 5 comments · Fixed by #41
Closed

Unable to link all scene datas to loaded scenes. Linked 0/1 #40

VirtualMaestro opened this issue Jul 31, 2024 · 5 comments · Fixed by #41
Assignees
Labels
bug Something isn't working released

Comments

@VirtualMaestro
Copy link

After the upgrade to the vesion 3.0 I'm getting this error:
Unable to link all scene datas to loaded scenes. Linked 0/1.

Unable to link all scene datas to loaded scenes. Linked 0/1.
UnityEngine.Debug:LogError (object)
MyGameDevTools.SceneLoading.SceneDataUtilities:LinkLoadedScenesWithSceneDataArray (MyGameDevTools.SceneLoading.ISceneData[],System.Collections.Generic.IList`1<MyGameDevTools.SceneLoading.ISceneData>) (at ./Library/PackageCache/com.mygamedevtools.scene-loader@b0a767ef89/Runtime/Utilities/SceneDataUtilities.cs:72)
MyGameDevTools.SceneLoading.AdvancedSceneManager/<LoadScenesAsync_Internal>d__30:MoveNext () (at ./Library/PackageCache/com.mygamedevtools.scene-loader@b0a767ef89/Runtime/AdvancedSceneManager.cs:199)
UnityEngine.UnitySynchronizationContext:ExecuteTasks ()

All scenes are added to the Build Settings.

        private static readonly ILoadSceneInfo MainSceneInfo = new LoadSceneInfoName("Assets/Client/Scenes/Main.unity");

        private ISceneManager _sceneManager = new AdvancedSceneManager();
        private ISceneLoader _asyncSceneLoader = new SceneLoaderAsync(_sceneManager);

            _asyncSceneLoader.Manager.SceneLoaded += _OnSceneLoaded;
            _asyncSceneLoader.LoadScene(MainSceneInfo, true);

        private void _OnSceneLoaded(Scene scene)
        {}

Thanks

@joaoborks joaoborks self-assigned this Jul 31, 2024
@joaoborks joaoborks added the bug Something isn't working label Jul 31, 2024
@joaoborks
Copy link
Member

Hi @VirtualMaestro, thank you for reporting this issue.

At first glance, it looks like the issue is related to loading the scene by its path. Did you try to load the scene by its name instead?

I think the package does not test loading scenes by path. I'll check whether that's the case and take a closer look at your report later today.

@VirtualMaestro
Copy link
Author

I don't know if it should work now with the latest 3.0 version, but it definitely worked with the previous version 2.x.

@joaoborks
Copy link
Member

Yeah, since 3.0 introduced "scene linking", now the loaded scenes must be matched with their load scene info. In 2.x that was the case only for addressable scenes.

Loading a scene by its path should work, so this is definitely a bug.

When linking the loaded scene, as of 3.0.0, it only compares the ILoadSceneInfo reference to the scene name, not the path.

namespace MyGameDevTools.SceneLoading
{
    public readonly struct LoadSceneInfoName : ILoadSceneInfo
    {
        // [...]
        public bool CanBeReferenceToScene(Scene scene) => scene.name == _sceneName;
        // [...]
    }
}

I believe that the fix is just adding a comparison to the scene.path as well, but I need to add tests to ensure that this is a reliable behavior.

@joaoborks
Copy link
Member

I have successfully reproduced the issue with updates to the Play Mode Tests. By simply adding LoadSceneInfoName with the scene path in the tests, they started to fail and log the same output you reported.

image

Then, after applying the suggested fix from the previous comment, it worked:

-        public bool CanBeReferenceToScene(Scene scene) => scene.name == _sceneName;
+        public bool CanBeReferenceToScene(Scene scene) => scene.name == _sceneNameOrPath || scene.path == _sceneNameOrPath;

image

If the tests succeed in the MR pipeline, then a fix will be deployed today.

@joaoborks
Copy link
Member

🎉 This issue has been resolved in version 3.0.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants