Hi, is there a way for my game to load faster in a browser by my loading scenes only as the player needs them instead of loading the entire game from the moment they load the game index.html page? please.
Hello silverglade007,
Yes, take a look at Unity - Scripting API: SceneManagement.SceneManager.LoadScene and the ‘Additive’ LoadSceneMode (Unity - Scripting API: LoadSceneMode)
Best,
Thanks very much Ignacio. To make this script work with a scene, do I create an empty game object and attach the script? Also, will I need a loading progress bar for each scene? Please. Thank you.
Hello silverglade,
There are no fixed rules on how to approach this, but usually yes, you’d have a ‘Manager’ object with a script attached to it in order to take care of all this stuff.
As for the loading bar, one way to do it would be to have a ‘Loading Bar’ prefab object that you instantiate right before loading a new scene instea of having a separate loading bar element for each scene. This way, if you make any changes to the loading bar prefab, you don’t have to go and tweak the loading bar for each scene.
Also, I re-read your original message and realized that you want to load one level at the time. If that’s the case, then the ‘Aditive’ LoadSceneMode might not be what you need. The ‘Single’ (Unity - Scripting API: SceneManagement.LoadSceneMode.Single) mode might be useful as well.
Try to do a small project that starts with a scene and swiches to a new one by pressing a button. This way, you’ll understand the problem and the solution better, and then you’ll be able to integrate it into your existing game a lot faster.
Best,
Awesome. Thank you for writing that. I will do what you said.Thanks for taking the time. Happy Spring.