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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

How do I preload multiple scenes?

Discussion in 'Scripting' started by mezzaninex, Jan 11, 2021.

  1. mezzaninex

    mezzaninex

    Joined:
    Dec 24, 2020
    Posts:
    2
    I have a hub world, and when I get close to a new area I'd like to preload the scene for it.
    Sometimes I'd like to preload multiple scenes, like if I am in a small town that has multiple buildings the player can go into.

    Looking at the existing questions and answers online, I have started digging into using
    Addressables.LoadSceneAsync
    to preload my scenes when a player gets close to a new area, and then activating the async loaded scene when the player enters one of the new areas. When a player gets far away, I would like to use something like
    Addressables.Release
    to free the pre-loaded scene that is no longer likely to get used.

    I am blocked because it seems like there is a big limitation (or documented bug?) in
    Addressables
    though: if
    SceneInstance.allowSceneActivation
    is
    false
    , then
    Addressables
    is blocked from loading anything else.
    This is stated in the documentation here but the reason is not elaborated on:
    When allowSceneActivation is set to false then progress is stopped at 0.9. The isDone is then maintained at false. When allowSceneActivation is set to true isDone can complete. While isDone is false, the AsyncOperation queue is stalled. For example, if a LoadSceneAsync.allowSceneActivation is set to false, and another AsyncOperation (e.g. SceneManager.UnloadSceneAsync ) is initialized, the last operation will not be called before the first allowSceneActivation is set to true.​

    With this limitation, is it possible to accomplish my goal of preloading multiple scenes at once?
    If it is not possible, can this limitation be eliminated somehow?
    Thanks for your input.
     
  2. mezzaninex

    mezzaninex

    Joined:
    Dec 24, 2020
    Posts:
    2