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

Massive lag when changing scenes.

Discussion in '2D' started by Ham5andw1ch, Jul 8, 2015.

  1. Ham5andw1ch

    Ham5andw1ch

    Joined:
    Jul 8, 2015
    Posts:
    2
    I am making an endless game in unity 2d. The screen layout resembles flappy bird, and as such has obstacles, your score, you, and your controls. The main menu is part of the same unity scene and appears when the app starts and when you die. You can buy characters, which are just sprite changes in the shop. The shop is in a separate scene. The scene change was just fine, but after adding music to both scenes, and more costumes, it takes 8 seconds to go from menu to shop. 12 seconds to go back to menu. Switching to the credits scene is instantaneous, but going back takes 6 seconds. This doesn't seem like much, but I'm sure users will find it unacceptable. How do I fix this?
     
    Last edited: Jul 8, 2015
  2. itzclay36

    itzclay36

    Joined:
    Apr 11, 2015
    Posts:
    25
  3. Pharan

    Pharan

    Joined:
    Oct 28, 2013
    Posts:
    102
    I only ever have this problem if I have procedurally generated meshes and they're still unbaked (have to be regenerated every scene load).

    You may have something similar going on. Not meshes specifically but might be computationally heavy things happening on Start or Awake. You may also be unnecessarily loading and unloading resources all the time.

    But yeah, Profiler will take some of the guesswork out. There was a recent official tutorial video about it for beginners if you don't know how to use it yet.
     
  4. Ham5andw1ch

    Ham5andw1ch

    Joined:
    Jul 8, 2015
    Posts:
    2
    I solved it. I didn't realize there was unity answers and posted to it afterwards. I just moved everything to the same scene and set the active status of canvases. It takes longer to start up, but it's better than loading the scenes over and over again. I think this is how crossy road did it.
     
  5. flywing12

    flywing12

    Joined:
    Jan 14, 2017
    Posts:
    7
    How can i permanently destroy an gameobject when i reload a scene, what I want is when i press start game , the button "start" permanently destroy in the hierarchy. But whenever I reload a scene its still there.. any tips on how to do that?

    same as flappy bird restart button, excluding the start button