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

SceneManager.Internal_SceneLoaded() takes progressively longer to run.

Discussion in 'Editor & General Support' started by noonche, Dec 15, 2018.

  1. noonche

    noonche

    Joined:
    Jul 7, 2013
    Posts:
    3
    I'm working on a fairly 2D-style game. We transition scenes by just calling SceneManager.LoadScene(). After this has happened about a dozen times our load times get longer and longer. Investigating this in the profiler yields this:

    Profiler Sceenshot.PNG
     
    goldcloud144 likes this.
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,589
    It looks like your game subscribed multiple times to scene related Unity events, such as the SceneManager.sceneLoaded event, for example.

    Perhaps you subscribe to this even in an Awake or Start call that executes every time a new level us loaded?

    What Unity version do you use? Did you perhaps just upgrade to 2018.3 and it did work in earlier versions just fine?
     
    goldcloud144 likes this.
  3. noonche

    noonche

    Joined:
    Jul 7, 2013
    Posts:
    3
    Yeah, that was it. I had a bug in my code where a single component could register multiple times to receive SceneManager.sceneLoaded. Thus the longer you played the more times this could stack up.

    Out of curiosity, is this just something you've seen before or is there something that I'm overlooking in the profiler that would have pointed me to this issue?

    Thanks for the help!
     
    goldcloud144 likes this.
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,589
    I have seen how delegates look in the Profiler before, but guessed it could be related to the SceneManager.sceneLoaded callback, due to the name:
     
    goldcloud144 likes this.