Additive scene loading is one possible solution:
I always favor breaking the scenes up and loading additively.
reduces overall memory consumption
lets multiple team members trample on each other less often
ensures clean "reset" of all objects in a fresh loaded scene
I'm working on a game now where we each have our own "content" level, the level we're working on.
the content scene has all the lighting baked in.
Just press play and that level has one script that additively loads:
music scene (just an audiosource on autoplay)
the p…
Glad you asked… going this route definitely requires slightly-higher awareness of what scene is what.
In no particular order, responding to you questions,
When the game or level is over, I try to go to a fresh “end level” scene (not additively!) and clear everything else out (except overall ongoing game manager obviously, as a singleton)
when the game gets paused I stop time and bring up a pause scene that sorts above all else, then unload it and restart the time. OR if you quit, I just …
There are underlying reasons this happened and you can track it down by examining everything about each scene's canvas setup and scaling that are different from the other.
But keep in mind it might not be super-easily to address it in the general case, especially if you start partitioning your UI into chunks.
An alternate workflow is to put chunks of your UI into separate scenes and then load those scenes additively.
For instance you might have the following scenes, all loaded additively:
…
A multi-scene loader thingy:
My typical Scene Loader:
SceneHelper.cs
/*
The following license supersedes all notices in the source code.
Copyright (c) 2021 Kurt Dekker/PLBM Games All rights reserved.
http://www.twitter.com/kurtdekker
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
This file has been truncated. show original
Other notes on additive scene loading:
Why not remove the player from ALL your scenes, put him in his own separate scene, then load scenes additively?
That way you don’t even need a Player prefab at all, just have a Player scene and load him additively.
I tend to break up all my games into partial scenes, all additively loaded by the game manager:
UI
player
enemy manager
other stuff?
and then finally I load the content scene.
The first batch of screens all have scripts that do nothing until the content scene appears and they kn…
Timing of scene loading:
If line 8 relies on something being present from the scene load in line 7 (in GameController), it won't be: scenes are loaded at the end of frame and would never be available until the next frame, at the very earliest.
You can trivially make void Start() into a coroutine by declaring it to return an IEnumerator, then put a while loop (with a yield return null; in it!!!) to wait until the scene loads and you find the "Trains" object, then proceed.
Obviously you would need to interlock other t…
Also, if something only exists in one scene, DO NOT MAKE A PREFAB out of it. It’s a waste of time and needlessly splits your work between two files, the prefab and the scene, leading to many possible errors and edge cases.
1 Like