- Home /
Load menu via SceneManager
Hello,
I'd like to know if it's a good or bad idea to load the main menu, options and other GUI-stuff via the SceneManager's async-method (additive) into my game (Unity3D).
The idea behind is that the game might not need so much memory if I load all of the GUI (main menu, options, level selection, achievements, etc.) asynchronously (additive) in my game. Please - can someone help me, please?
This is some code I found but it doesn't work:
IEnumerator loadNextScene()
{
string name = "ALegitSceneName";
AsyncOperation _async = new AsyncOperation();
_async = SceneManager.LoadSceneAsync(name, LoadSceneMode.Additive);
_async.allowSceneActivation = false;
while(!transitionIsDone)
{
yield return null;
}
_async.allowSceneActivation = true;
while (!_async.isDone)
{
yield return null;
}
Scene nextScene = SceneManager.GetSceneByName(name);
if (nextScene.IsValid())
{
SceneManager.SetActiveScene(nextScene);
SceneManager.UnloadScene(SceneManager.GetActiveScene().name);
}
}
Okay first of all, if it's main menu, wouldn't it originally be loaded on launching the application? if so, why load it a second time? Just keep the original load, OR if your main menu doesn't require a 3D scene background, you can just make your entire main menu a resource and load it at launch, then instantiate it when loading new scenes, this way it's already in the ram as a resource, and instantiating copies of it won't be that bad on the ram. I can't imagine your UI takes more than 10-20mb of RA$$anonymous$$, anything more would be insane unless your game is UI based. Just remember, the absolute 2 largest objects in term of space in the RA$$anonymous$$ will always be Textures and Audio, so just avoid using too many high-res elements in your UI and it shouldn't cost much.
Your answer
Follow this Question
Related Questions
Load Level in background and load it when key is pressed 2 Answers
LoadSceneMode.Single seems to be not working. 0 Answers
Loaded two scenes asynchronously, neither will activate? 1 Answer
How to make a gameobject take you to a scene when clicked? 3 Answers
Load A Scene In A Separate Project 2 Answers