Search Unity

Having one scene for the whole game

Discussion in 'Scripting' started by Pixitales, May 10, 2019.

  1. Pixitales

    Pixitales

    Joined:
    Oct 24, 2018
    Posts:
    227
    Can I have one scene for my whole game using enable and disable 30+ level 2D pixel tile maps? Will this have a impact of the game being slow?
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,445
    Think of a Scene is just another container like an Empty game object, and you can load it when it's needed like a Prefab.

    Your approach is going to be a memory hit, not a speed hit. If each level is really not much data, enabling and disabling them may work, but it seems to me that the better design would store all that level data into a format you can load and destroy, such as prefabs or scriptable objects or scenes loaded additively.
     
  3. blastedw

    blastedw

    Joined:
    Apr 29, 2019
    Posts:
    13
    Go with a Scene per Level. However for my menus I use just one Scene and DoozyUI views to swap them in/out.
     
  4. justLC

    justLC

    Joined:
    Oct 16, 2018
    Posts:
    45
  5. Deleted User

    Deleted User

    Guest

  6. Pixitales

    Pixitales

    Joined:
    Oct 24, 2018
    Posts:
    227
    I will have a lot of scenes if I do that. If I want to change something in my level scene like 30+ levels, I will have to go each one by one and change.
     
  7. justLC

    justLC

    Joined:
    Oct 16, 2018
    Posts:
    45
    You can also store each level in a GameObject and only enable the active one
     
  8. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,445
    If you have stuff which is identical in each scene, then put that stuff in a shared scene or prefab.

    If you need to change something unique in 30 scenes, that's just the nature of development... you will either have to open and find that stuff in 30 places in the same hierarchy (annoying) or you will have to open and find that stuff in 30 scenes (annoying).
     
  9. sunnydestiny71

    sunnydestiny71

    Joined:
    Jun 12, 2020
    Posts:
    1
    Hello Everyone, I know this trend is old. But looking at a game like Orbia for mobile with over 1000 levels. while playing it, it all looks like it's being played on only one scene. or is there a way to disable processes or movements while the game object is off camera?
     
  10. DragonCoder

    DragonCoder

    Joined:
    Jul 3, 2015
    Posts:
    1,700
    Yes and rendering is automatically disabled off camera. Mechanics and physics-related objects have to be disabled and enabled "manually" though. Note that "disabled" does not mean the memory is freed! Therefore you'd have to fully destroy and create dynamically, meaning you need a custom way of storing the level design (which for a game like Orbia is surely not too hard). If you do go such a route, read up on "object pools" as those will improve performance.

    However for a classic platformer etc. simply using separate scenes is the way less head aching way of designing a game and it's possible to load scenes asynchronously, so the actual transition from one scene to another will not require a loading screen.
     
  11. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,500
    Let's not continue necroing/hijacking this super old thread that isn't even related to 2D at all.

    Please create your own thread in the Scripting forum.

    I've also moved this thread to the Scripting forum where it belongs.

    Thanks.