Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Stuck loading scene SceneManager.LoadSceneAsync additive

Discussion in 'Editor & General Support' started by Samacvuk, Oct 7, 2017.

  1. Samacvuk

    Samacvuk

    Joined:
    Jan 8, 2017
    Posts:
    30
    Greetings all,

    My game has a persistent scene and I load all the levels with SceneManager.LoadSceneAsync additive in a coroutine, now the Unity editor freezes when loading the initial scene of the game into the persistent scene, don't have a clue to what could have caused this, nothing was changed it just stopped working overnight.



    How do I fix this?


    Thank you all

    EDIT1: In this particular case an instance of a gameObject was causing a stack overflow before the scene could be properly loaded causing the editor to not respond on windows 10.
     
    Last edited: Oct 7, 2017
  2. Siyka

    Siyka

    Joined:
    Aug 17, 2014
    Posts:
    10
    Hi, I have the same problem loading scenes on both Windows 10 and OS X. The editor spins forever. I also cannot build for iOS without any reasonable error. Unity 2017.2.
     
  3. Samacvuk

    Samacvuk

    Joined:
    Jan 8, 2017
    Posts:
    30
    Hello Mr. Dobri,
    did you check the task manager to see if the unity editor process stopped responding?
    if yes it is most likely some loop or recursive call in your program that is locking the game loop and causing the editor to crash, in my case above it was an AI planning loop that was calling itself over and over
     
  4. Siyka

    Siyka

    Joined:
    Aug 17, 2014
    Posts:
    10
    Hello Mr Samacvuk,
    You are right. Code to load another scene executed too early, maybe before the scene was completely loaded (the script was simply attached to scene game object). To make scenes load again I had to move all code from Start() method of the script that loads with the scene to a coroutine. The same code in a coroutine does not crash the editor. I did the following: destroy all scripts on old scene; yield return null; load new scene; yield return null; start new scripts. The problem with building for iOS I managed to solve by importing all standard packages such as image effects again, delete Library folder, wait for unity to rebuild it and finally reimport all assets.