Search Unity

Too Many Scenes?

Discussion in 'iOS and tvOS' started by LimeSplice, Jul 18, 2011.

  1. LimeSplice

    LimeSplice

    Joined:
    Jul 15, 2011
    Posts:
    111
    Hi

    I'm making a game that requires a level up (to 50 levels), and was planning to put each level in a new scene (as there are differences from scene to scene with number of actors etc).

    Can you have too many scenes? I thought this might have been a good way to only load what's required, rather than the entire game into one scene.

    Is this the best approach? Cheers for any advice :)
     
    BrandyStarbrite likes this.
  2. zine92

    zine92

    Joined:
    Nov 13, 2010
    Posts:
    1,347
    Wow for 50 levels, i don't think there's any restrictions and actually if theres some common things, might as well combine a few levels into a scene. Say 5 levels per scene. Depending also. Or you can have something like a scene where it loads a .txt file which reads and assign the level. Say a .txt file which contains certain info like levels and uses that .txt to "recontruct" the level thus you only need 50 .txt rather than 50 .unity scenes.
     
  3. LimeSplice

    LimeSplice

    Joined:
    Jul 15, 2011
    Posts:
    111
    Thanks zine, yeah was thinking of combining levels into batches, however, the way the code is I've spent weeks trying to get it to work correctly (adding to a random array), and haven't been able to (I'm still quite a novice 'coder')... so my only solution was to break all the levels down into scenes... Not sure how to use a .txt file to do this though - didn't think you could! I'll have a look around and see if that could help me... thanks
     
  4. zine92

    zine92

    Joined:
    Nov 13, 2010
    Posts:
    1,347
    I think splitting in batches would be fine for now. And when you have the time, you can try the txt method. The txt method will allow for run time reading of levels which can be change before runtime. :D
     
  5. spentak

    spentak

    Joined:
    Feb 11, 2010
    Posts:
    246
    You can have as many scenes as you want. One of the games I made http://itunes.apple.com/us/app/word-warrior/id400289406?mt=8 Word Warrior, had over 50 scenes..each scene had a lot of content too. The content was built with prefabs too, which means file size was ridiculously low. You could easily do an angry birds with 300+ scenes without any problems. Think of games like Portal 2- You go through well over 100 "loading" sections where it loads a new "scene". This is what Unity is all about.
     
  6. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,627
    This is the POINT of having scenes in the first place. One per level, regardless of how many you have. There's no overhead and they are tiny. It would be far buggier not to :)

    It's a bit bad to combine multiple levels into one scene, you're only hurting yourself. Just do one scene per level - thousands would work fine. There's no upper limit.
     
    skauth and BrandyStarbrite like this.
  7. Rush-Rage-Games

    Rush-Rage-Games

    Joined:
    Sep 9, 2010
    Posts:
    1,998
    Yep, you can never have too many scenes! ;)
     
  8. MikaMobile

    MikaMobile

    Joined:
    Jan 29, 2009
    Posts:
    843
    It depends on how your game is built, but having lots of scenes might cause problems if/when you add features down the line. Let's say you make 50 levels, and then decide later that you want to add an "options" menu that can be accessed mid game. You'd potentially have to add this menu 50 times to 50 different scenes, unless you build it in a way that's easily plugged into any scene as a prefab or entirely through script. It may not be a huge deal, but it can complicate the process of adding new things. On the plus side, its nice and organized.

    I'd run into issues like this myself when building OMG Pirates, so to make my life easier I used only a single scene for Battleheart, and had all 30-ish levels constructed dynamically via script. The enemies, background art, etc. are all loaded into this one master scene from the Resources folder on Awake(), so if I make any fundamental changes (for instance, changing the camera FOV or something) I don't have to do it 30 times.
     
  9. spentak

    spentak

    Joined:
    Feb 11, 2010
    Posts:
    246
    Mika
    Can you elaborate on your loading of your levels "via script"? What do you mean exactly? If level == 1 then instantiate enemy at x,y,z?Also as for loading resources on Awake(), you load your entire game's resources at the beginning and have those in memory the whole time? Or how does that work?

    On one of my games I ran into the problem with many scenes and feature changes, so I of course made everything into prefabs, and I also had a "filler" prefab for any little thing that might come later. So 1 giant filler prefab with other prefabs in it.

    Is that a bad approach in your opinion?
     
  10. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,627
    Mika makes a good point, and to address this you could for example make all "non level stuff" like options in its own script which is not destroyed on load.
     
    BrandyStarbrite likes this.
  11. MikaMobile

    MikaMobile

    Joined:
    Jan 29, 2009
    Posts:
    843
    @marklennartprice - all of the battles in Battleheart take place in the same scene. That scene is empty except for a camera, the UI, a big untextured polygon used for the background, and an empty gameobject with a script attached that manages the game. Before arriving in this empty scene, the player had been in a "menu" scene where they chose which battlefield to go to, but these all connect to the same scene. The only difference is what background art, enemies, and party members are instantiated upon entering that scene.

    Basically, anything that differentiates your 50 levels can either be manually placed into 50 discreet scenes... or you can write a system that procedurally recreates those levels in a single scene. I'm not saying one is "better" than the other, but there are some advantages to consider either way. And yes, in some cases you could add something after the fact to 50 scenes by creating it once and setting it to not destroy on load.
     
  12. LimeSplice

    LimeSplice

    Joined:
    Jul 15, 2011
    Posts:
    111
    Thanks everyone for your input. You're right Mika - didn't think of that. I always use prefabs as much as I can, particularly with menu stuff on game screens, so hopefully it won't be an issue. (I still haven't gotten use to the GUI side of Unity yet, so I make 2D button instances lol)
     
  13. LimeSplice

    LimeSplice

    Joined:
    Jul 15, 2011
    Posts:
    111
    @marklennartprice your game looks awesome - is that all 2D sprites?
     
  14. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    1,164
    Wow!
    I know this is an old post.
    But this is an interesting read. :D
    Thanks for this info guys.
     
  15. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    473
  16. skauth

    skauth

    Joined:
    Jun 4, 2017
    Posts:
    16
    So I just accomplished this in my own game. (I know this is post old, but whatevs.)

    Totally not true. Instead of doing this:
    Code (CSharp):
    1. SceneManager.LoadScene(sceneName)
    do this:
    Code (CSharp):
    1. SceneManager.UnloadSceneAsync(oldScene)
    2. SceneManager.LoadScene(sceneName, LoadSceneMode.Additive)
    This will allow you to have multiple scenes open at any one time. Remove the cameras from all the new scenes you create and just stuff the content in there. Use one scene to store all your menu stuff.

    For reference, I'm making a 2D TopDown RPG. Every time you go through a door, I unload the current content scene and load the next content scene (Say 'Town' and 'Hut1'). The Camera, UI, Player, and Managers are all in the 'Main' scene. Any npcs will go in the content scenes. If an NPC is going to follow the player through doors, I'll make it jump to the Main scene. Or I'll make her/him duplicated for each room. I haven't decided yet. Kinda goes along with the debate of making different objects for each quest stage of one npc, or making the one object change.