Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Having trouble with loading SubScene at runtime

Discussion in 'Entity Component System' started by bfisk121, Oct 4, 2023.

  1. bfisk121

    bfisk121

    Joined:
    Jan 24, 2020
    Posts:
    6
    I'm trying to load subscenes at runtime, but I'm struggling quite a bit and all code I've found online seems outdated. I'm on Unity 2022.3.10

    I found this page: https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/streaming-loading-scenes.html. And from what I understand, the System here checks in OnUpdate if it has received any requests and if it has then it loads the scenes associated with the requests.

    But I have no clue how to send in a request to this system. How am I able to add to the EntityQuery from some other file?

    I should also mention I'm very new to DOTS, so I may need some pointers to other pages that will help me learn how to do this.

    Thanks!
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,574
  3. bfisk121

    bfisk121

    Joined:
    Jan 24, 2020
    Posts:
    6
    It's really challenging looking through whole projects when I'm such a beginner and looking for a pretty specific thing.

    Is the interpretation of the code I already found even correct? It seems like an EntityQuery is used to find all objects of the type(s) given. So in the example I found, it would be used to find all SceneLoaders. So do I add an object to the EntityQuery by simply creating a new SceneLoader object?

    Is that the right interpretation at all? If so, my next question would be what happens to the SceneLoader objects after it's processed by the EntityQuery - will they get destroyed? Or will they continue to exist in the EntityQuery? If its the latter, wouldn't the system try to load the same scene on every frame?
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,574
    No. At the game start, it loads once, when baking happening.
    Checkout Window -> Entities -> Hierarchy, for better understanding entities.