So I’ve been working all of this time with a single scene for my game.
The idea I have to keep things simple is to use the primary scene I’m working on now as a kind of prefab, copying, pasting and renaming the scene to use it as a template for other scenes.
In the tutorial I’m taking this is the basic logic:
sm = SceneManager.LoadSceneASync(1);
sm.allowSceneActivation = false;
while (!sm.isDone)
{
etc... etc...
}
So two things…In Unity, the idea is that you go into Build Settings… then click and drag your scenes around, and that determines two things (from what I’m understanding), and that’s A) which scene is loaded first and B) scene id numbers.
There’s logic that I’m not quite wrapping my head around.
in the code above where it says ‘LoadSceneASync(1)’, that’s the scene’s id number right? But the thing is, this loading screen will just be tacked onto every single scene…So is there like a LoadThisSceneASync function or something?
Is the idea that you create a master scene in your game that’s like a scene manager scene, and that’s where you’d place the loading screen?
How do global variables across scenes work, then? < — The thing I’d like to know most by far.
2: I don’t think you need a scene-manager scene, but it depends on the game. Typically, I’d put the loading screen before a scene that takes a while to load. If your scenes are very simple and load in fraction of a second, it’s not even worth the bother.
3: That is very interesting. As far as I know, static variables will save their values between scenes. If there’s something you need to save between scenes, you can use PlayerPrefs or serialize a binary file, or some other way of saving game data. Personally, I like putting as much in 1 scene as possible, as it reduces load times. Some people even put their start menus into the game scene (if there’s one game scene) for faster loading.
Thanks guys, this clarifys everything for me. I’m creating a game making environment for myself in where there is a main game scene called “0_MG” with a main game object called MG and then scenes load after that one, so the DontDestroyOnLoad thing is huge for me. I’m trying not to use static variables at all since people have advised against it, but I can just have all of my global variables attached to an MG object that doesn’t die. It makes it much simpler for me as I’m used to working in other game creation environments.