Search Unity

Application.LoadLevel not working on android

Discussion in 'Scripting' started by Broller, Apr 26, 2014.

  1. Broller

    Broller

    Joined:
    Feb 28, 2014
    Posts:
    28
    Hi. I use Application.LoadLevel to open my level and it was working fine. Now it won't work anymore. I did some corrections, I deleted some items and everything is working fine inside Unity and on Windows Phone but Application.LoadLevel doesn't work on Android. Any fixes for this?
     
  2. Akelator

    Akelator

    Joined:
    Oct 1, 2014
    Posts:
    1
    The same problem :(
     
  3. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    assume youre including the scene in the build...

    works fine for me.
     
  4. Vipsu

    Vipsu

    Joined:
    Oct 8, 2012
    Posts:
    88
    If I recall correctly Unity keeps both scenes in the memory when loading the scene, this can cause the device to crash due to lack of memory. To go around this, you can simply create an empty scene called "LoadingScene" or something. Load that first and from the loading screen scene you can load the next scene.

    This allows unity to deload the previous scene from memory and load up the next one and since the scene is almost empty there wont be memory problems.

    To pass data to loading screen you can use static class with static string or int variable that tells the next scene or some sort of persistent gameobject.