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

How to async loading scene in editor?

Discussion in 'Editor & General Support' started by kbop2000, Sep 14, 2020.

  1. kbop2000

    kbop2000

    Joined:
    Apr 17, 2019
    Posts:
    14
    hello

    I want async loading scene in editor ..

    Because, in my project, it is a project that creates only scenes without using build
    When there are many objects in the scene the loading speed is slow, so I will try to explain why I load while waiting using the prograss bar

    is there a good way?
     
    Last edited: Sep 14, 2020
  2. justLC

    justLC

    Joined:
    Oct 16, 2018
    Posts:
    45
  3. kbop2000

    kbop2000

    Joined:
    Apr 17, 2019
    Posts:
    14
    Oh, I just added an explanation, but if I say specifically...


    Selecting an object selects the Asset file in the Unity file and calls the Scene file.
    Scene is divided into several




    Actually the Scene is not used, it is used to store the Xml. However, the more Scene objects, the longer the loading time
     
  4. kbop2000

    kbop2000

    Joined:
    Apr 17, 2019
    Posts:
    14
    SceneManager.LoadSceneAsync is error ..
    This can only be used during play mode, please use EditorSceneManager.OpenScene() instead

    i want to use in edit mode t-t
     
  5. justLC

    justLC

    Joined:
    Oct 16, 2018
    Posts:
    45
    I guess we need to take a look at your code to provide help.
     
  6. kbop2000

    kbop2000

    Joined:
    Apr 17, 2019
    Posts:
    14
    Code (CSharp):
    1.  
    2. // ..
    3. string title = asset.name;
    4.             EditorUtility.DisplayProgressBar(title, "", 0f);
    5.             try
    6.             {
    7.                 if (!asset.version.Equals(LastVersionPatcher.Version) ||
    8.                 !asset.versionNumber.Equals(LastVersionPatcher.VersionNumber))
    9.                 {
    10.                     EditorUtility.DisplayProgressBar(title, "Update tale version ..", .5f);
    11.  
    12.                     using (LastVersionPatcher patcher = new LastVersionPatcher(asset))
    13.                         patcher.OnStart();
    14.                 }
    15.  
    16.                 EditorUtility.DisplayProgressBar(title, "Load scene ..", 1);
    17.  
    18.                 SSSceneTool.ActiveTale = asset;
    19.                 SSSceneTool.ActiveScene = asset.ActiveScene; // Here!
    20.             }
    21.             catch (System.Exception e)
    22.             {
    23.                 Debug.LogError(e.Message);
    24.             }
    25.             finally
    26.             {
    27.                 EditorUtility.ClearProgressBar();
    28.             }
    29. // ..
    30.  
    SSSceneTool.ActiveScene in calling
    EditorSceneManager.OpenScene(value.GetScenePath, OpenSceneMode.Single);


    'LastVersionPatcher patcher' can be ignored

    + Many objects are in the scene
    I'll show you a picture of the project being used ..

     
    Last edited: Sep 14, 2020
  7. justLC

    justLC

    Joined:
    Oct 16, 2018
    Posts:
    45
  8. kbop2000

    kbop2000

    Joined:
    Apr 17, 2019
    Posts:
    14
    The framework is what I made.. haha
    In summary, I simply wanted to load SceneManager.LoadAsyncScene in the Editor.

    My English is bad t-t..
    Thanks for the reply!
     
  9. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Last I checked (2018.2.21), async scene loading is always blocking within the editor. It works actually async in a build. I doubt it has changed since then. (I'd love to find out if there actually is a way though)
     
    kbop2000 likes this.
  10. Corvinus_

    Corvinus_

    Joined:
    Dec 31, 2013
    Posts:
    1
    To load the scene as well as of your current scene when not in play mode:

    #if UNITY_EDITOR
    EditorSceneManager.OpenScene("Assets/Scenes/whatever.unity", OpenSceneMode.Additive);
    #endif

    include in header:

    #if UNITY_EDITOR
    using UnityEditor;
    using UnityEditor.SceneManagement;
    #endif