Approaches: Multi Scene Organization?

About a week or so ago I finally put together a multi scene approach for splitting out some UI, with each panel living in a different scene and some simple tools to make that setup as easy as possible to work with.

I didn’t do my homework before I started the effort, and failed to take a look around at how others approached this kind of thing.

This is the rough result I ended up with:

And in the project browser…

And finally, this is the main bit of code:

    public static readonly Type[] PanelSceneTypes = new[]{
      typeof(WorldUITownMenu),
      typeof(WorldUIFightPrompt),
      typeof(WorldHUDLocation),
      typeof(WorldUIQuestPanel),
   ...

Scenes are just loaded by parsing the class name. The buttons on the panel above are to make it super easy to load and unload specific scenes.

The bootstrapper is fairly simple and just loads in each scene with a little extra stuff to help keep everything well ordered (make sure things all start at the right time, etc). Code was pretty simple, took about a day to write and a day to test.

It’s working alright so far, but I am not asking it to anything super complex yet either.

The main goal is to better deal with complex gui hierarchy. I’ve personally found that world space stuff is not that bad to navigate, but ui tends to get really annoying very fast as the hierarchies blow out and it becomes impossible to find stuff.

I’m sure some of you guys have worked with insane systems for this kind of thing - anyone feel like sharing?

I am using the multi-scene feature extensively. I had to use it in order to get around the 4GB size limit for a scene. I have a loading scene that handles the initial loading progress bar for the game, and that is where I asynchronously load each of the additional scenes additively.

The additional scenes are just for different subsystems. All of the levels/missions are generated procedurally, so there are not any typical level-centric scenes to load. But I could not reference all of the content from a single scene, because of the 4GB limit per scene.

Once all of the subsystems are loaded additively, one of my game objects has a script that finds each subsystem to cache a reference to each, and then everything takes off from there.

How did you hit the 4gig limit when using a procgen system? Can you share any details? I realize asking a game dev to share details is like asking a woman her age… but sharing some examples of real world setups can be pretty valuable I think.

Unity has a limit of 4GB of content that can be referenced by a single scene. In my game, I have subsystems for managing the placement of everything procedurally. This meant that those subsystems had references to all of the content. When all of my subsystems where in one scene, the total referenced content exceeded Unity’s 4GB limit per scene.

Here are a few threads about the 4GB limit:
https://forum.unity3d.com/threads/bug-4gb-limit-to-textures-in-standalone-build.441116/
https://forum.unity3d.com/threads/textures-messed-up-in-windows-build.440675/
https://forum.unity3d.com/threads/texture-problem-graphical-corruptions-need-help.395985/

When all of my subsystems were in one scene, I started having problems with some textures missing in the Windows builds. It would run fine in the editor, though, because the 4GB per scene limit only applies to the builds.

I also tried to resolve the 4GB limit using asset bundles, but that did not work. Asset Bundles crashed repeatedly, because apparently asset bundles are also very problematic with large scenes. Splitting my procedural subsystems across multiple scenes worked great.

Here is the post where I explained in more detail how I worked around the 4GB per scene limit:
https://forum.unity3d.com/threads/bug-4gb-limit-to-textures-in-standalone-build.441116/#post-2856655

In my space game, I have over 3GB of content referenced by my SpaceSceneCreator GameObject. My SpaceSceneCreator GameObject is something I created to procedurally generate 3D space scenes (including planets, nebulas, stars, and galaxies). My custom SpaceSceneCreator creates 3D space scene at runtime on a separate layer that the player’s camera cannot see. Then it bakes the entire 3D space scene into a 96MB cubemap skybox that gets attached to the player’s camera. When the player is flying through hyperspace to get to the next level/mission, my SpaceSceneCreator runs in the background to get the next level’s space background created on the fly. This solution provides the benefits of a really cool looking 3D space scene background without the performance penalty of trying render the 3D space scene in real time. Anyway, my SpaceSceneCreator subsystem is in its own scene now to get around the 4GB scene limit.

2 Likes