Hello,
I am developing a mobile game.
At start I am loading only the terrain, and the remaining objects(trees,animals,huts,…)
are being loaded inside function OnLevelWasLoaded().
I have some object who’s components are disabled and others who are deactivated in the inspector.
function OnLevelWasLoaded()
{
for(var i = 0 ; i < allAnimals.Length ; i++)
{
if(allAnimals*.renderer != null)*
_ allAnimals*.renderer.enabled = true;_
_ if(allAnimals.collider != null)
allAnimals.collider.enabled = true;
}*_
* parentObject.SetActiveRecursively(true);*
}
Note that parentObject is an emptyGameObject who holds all other objects.
Now my problem is that I am trying to avoid to load every asset from start to speed up loading time, but it makes no difference at all. (about 20 second) which is too much i guess.
I thought of Instantiating my objects after game loads, but its a complex work sine each animal,object have random places in the terrain (forest).
Is there an alternative way?
thanks,
It takes the same time, since it still needs to load everything to memory. Disabling it just tells it to avoid processing, not to avoid allocation of memory. And the best practice would still be managing a good loading mechanism to load only what you need before you need it.
– GuyTidhar@GuyTidhar thank you alot. For my scene I have all the animals already existing in the scene.. How can I not load them at start? I though of saving their positions in an Array of Vector3 objs, then remove them from the scene, and Instantiate them at runtime (with the positions I already have). But don't you think there must be a more handy way than this?
– moghes