- Home /
Loading assets through script or not?
I'm making a mobile game, and I was wondering if it is better to basically have a blank scene and have the map, player, player boundaries, etc, all loaded through a script, or to just save them in the scene beforehand?
Which is more efficient?
Thanks!
$$anonymous$$y guess is having it in the scene to begin with is probably better, but I don't have any information on why
Answer by wibble82 · Mar 07, 2014 at 05:02 PM
The general rule is that loading will be more efficient if you need to ask unity to do 'less' things. So if you can have all your objects in the scene and then just ask unity to load the scene it offloads all the work to the native unity code and will be very efficient.
The flip side of that is if you start to need to pick and choose what gets loaded, at some point just telling unity 'load all this stuff' will be less efficient than asking them to load one at a time.
My advice would be to start with the simple option - shove them in the scene. If it turns out that loading times are a big issue then you can look for cleverer approaches.
Another advantage having stuff in a scene does for you is that you can use functions like 'LoadLevelAdditive' to add things from another scene to your world, and even the asyncronous loading functions that allow your game to keep running while a load occurs.
Answer by GrnDyRx · Mar 07, 2014 at 04:58 PM
I am not an expert, but if you put it in the scene, unity would save it down in its system, which is probably very well optimized. If you put it in a script, unity saves your script, which it cannot optimize as well. So unless you're an expert, you're better off using a saved scene.
Your answer
![](https://koobas.hobune.stream/wayback/20220613135631im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Objects instantiated in wrong scene. 1 Answer
How to create GameObject without adding it to scene? 1 Answer
Instantiate A Prefab 1 Answer
Teleporter 2 Answers