Search Unity

Question [DOTS] Subscene works well in Editor, but won't load in standalone build.

Discussion in 'Entity Component System' started by Deleted User, Jan 14, 2021.

  1. Deleted User

    Deleted User

    Guest

    What I did:

    1. Step
    I was setting up a project by this instructions:
    https://docs.unity3d.com/Packages/com.unity.netcode@0.5/manual/getting-started.html
    Everything works fine in unity editor and in standalone build.

    2. Step
    I made use of a simple Subscene. Simply moved Plane and GhostCollection to the Subscene.
    (deleted SharedData item, seems not to be used any more.)
    I updated my build settings to include the new Subscene. Of course, reimported it in the editor.
    Everything works fine in the Editor.

    But the standalone build don't work with Subscene!

    It renders this error:
    NullReferenceException: Object reference not set to an instance of an object
    at Unity.Entities.EntityQueryImpl.GetSingletonEntity () [0x0001e] in D:\rde\try\UnityNetCode\NetCode3D\Library\PackageCache\com.unity.entities@0.16.0-preview.21\Unity.Entities\Iterators\EntityQuery.cs:703

    NetCode3D/Assets/NetCode/GoInGameServerSystem.cs Line: 16
    Entity ghostCollection = GetSingletonEntity<GhostPrefabCollectionComponent>();

    As I understand this, it's due to the Subscene isn't loaded in the standalone build, somehow, of which the GhostPrefabCollectionComponent is a child, and therefore not accessible.

    I have following questions:

    1. Why is the Subscene not loaded in the standalone build?
    2. Why we are facing different behaviours of Subscenes in editor vs. standalone build?
    3. How can I get the Subscene working in standalone build as expected, compatible with editor mode?

    Does any one has clue how to fix this issue?
    What should I do and how?
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    How are you building? You can't just use the regular old build settings.
    You have to use the new BuildConfiguration for subscenes to work.

    i.e. should be building with something that looks like this

    upload_2021-1-14_20-55-57.png
     
    andreiagmu likes this.
  3. Deleted User

    Deleted User

    Guest

    @tertle

    Yes, I'm using the regular old build setting of the editor. (Sorry, I'm new to unity)

    Now, I have set up a WindowsClassicBuildConfiguration, and the standalone build works! :D

    Thanks a lot!
     
    Last edited by a moderator: Jan 14, 2021
  4. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,759
    For some reason I don't believe this is documented at all in the entities manual.

    1. Pick your platform and download the appropriate package. For windows this is com.unity.platforms.windows so add this to package manager via the + button -> add package from git url -> write in com.unity.platforms.windows

    2. Create the build configuration for your platform. For example, this is found in the Assets -> Build -> Window Classic Build Configuration.

    3. Set it up however you need. You do not need to add subscenes to the scene list, only regular scenes.

    4. Hit Build (and run) in the top right corner
     
  5. trepan

    trepan

    Joined:
    Feb 11, 2011
    Posts:
    113
    Thank you so much for your post here @tertle.This seems like a pretty fundamental thing to apparently not be mentioned anywhere in the official documentation - what the heck?!

    Just to clarify for anyone about to make the same mistake that I did, build configurations show up in the Project (and the Build button is part of the Inspector); don't bother looking at Window -> Build -> Manager. I don't know what that window is for but nothing helpful it seems.
     
    Last edited: Apr 14, 2021
    bb8_1 and keeponshading like this.
  6. unitydev112

    unitydev112

    Joined:
    May 29, 2019
    Posts:
    14
  7. scottjdaley

    scottjdaley

    Joined:
    Aug 1, 2013
    Posts:
    163
    I found this to be true when performing builds on a windows machine with a target platform of windows. However, I recently set up a build pipeline that performs the builds on an linux VM, but still has a target platform of windows. In this case, the build succeeds and I don't have any errors (besides a seemingly benign SRP batcher error), but the subscene is just not loaded. I managed to fix this by adding the subscene to the scene list.

    In other words, it seems like building on linux for windows requires the subscene to be in the scene list.

    Here is my build configuration:

    upload_2022-1-20_11-34-2.png

    Just to be clear, "SubScene" is a subscene and it is included in the "Main" regular scene.

    Does anyone know if there is a downside to including the subscene in the scene list?
     
  8. nikk98

    nikk98

    Joined:
    Mar 8, 2021
    Posts:
    43
    I'm facing the same issue with Android, but adding the subscene in the list of scenes does not solve it.

    It works in the editor and on the built, iff I use mono as the scripting backend. If I use il2cpp, then the subscenes are not loaded.

    I've created a top level thread about this that has a link to a repo with the behaviour.

    Is il2cpp supposed to be working with subscenes on Android?
     
  9. yifanchu183

    yifanchu183

    Joined:
    Jul 4, 2019
    Posts:
    41
    I found even build for the windows platform, I also need to add the subscene to the scene list. I read the Loading scenes at runtime | Entities | 0.51.1-preview.21 (unity3d.com) found that the SceneSystem.GetGUID use "StreamingAssets/catalog.bin" file, the map from path to guid only generated after I add the subscene to the scene list