Hi Im using free Unity, so I cant use the loading method of the pro version.
Im trying to make a script by my own, to load the things one for one and dont get errors.
So, I was thinking, how can I get a better perfonmance. If I leavea all my scene(except the object with the script) SetActive(false), and then set them true in groups. Or Make differents prefab groups with my scene, and then instate them one group at time?
The easiest way to do this is with a Spawn Pool system, that instantiates and disables everything right as the level loads, so it happens within the first frame and doesn’t look like any sort of lag.
I know you are thinking of memory requirements and frame skipping, but I’ve never had any problems with my system.
Basically it works like so:
I have a scriptable object in my assets folder which contains data keys like so:
(Name, GameObject, NumberToSpawn)
I then have a lazy loaded static manager class called SpawnPool, which can be arbitrarily started from any class I deem fit.
This instantiates all of my objects at (0,0,0) and disables them.
When I need to “Spawn” something, I simple call:
GameObject Spawnable = SpawnPool("Arbitrary Name", Vector3.zero, Quaternion.identity);
The back end of the system will then check for every previously “Spawned” Object, and if they are now inactive, recall them to the spawn pool.
Then it searches for the new Object matching the key name and gives you a reference to it, and activates it.
It’s rather simple, and works like a charm too!
(Also works great on mobile!)
If you want I can attach the script, and the custom editor for it.
(Works on Unity Free)
Hope this helps!