Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Use Application.LoadLevelAdditiveAsync or enable/disable gameobject

Discussion in 'Editor & General Support' started by herbie, Sep 13, 2016.

  1. herbie

    herbie

    Joined:
    Feb 11, 2012
    Posts:
    237
    Hi,

    I'm working on an android 2D game like Limbo. The character walks from the left to the right and encounters several obstacles.
    I was wondering what's a better way to build the game:
    - divide the game in a lot of scene's that are loaded with Application.LoadLevelAdditiveAsync when the character approaches and destroy when the character is pass by, or
    - load the complete world with all the gameobjects disabled and enable them when the character approaches (and disable them again when the character pass by).

    Now my game is build like the first option with Application.LoadLevelAdditiveAsync but I have very small hiccups when a scene is loaded and I can't get rid of those hiccups.

    Who can give me some advice?
    Thanks.
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    2,869
    It depends on your Memory restrictions.
    If you can fit the whole level inside the memory of the target device, then you can just en / disable game objects of needed.
    The positive ting is that all the data is already loaded and you will not get any potential slowdowns do to loading.

    In case your memory does not allow all of the level to be loaded at the same time, use SceneManager.LoadSceneAsync ( it replaces Application.LoadLevelAdditiveAsync from 5.4 onward.
    just make sure to call SceneManager.UnloadScene for all part levels that will not be visited anymore.
     
  3. herbie

    herbie

    Joined:
    Feb 11, 2012
    Posts:
    237
    Ok it's clear. Thanks for reply!