deactivated or disabled object does not effect loading time!

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 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?

–

1 Answer

1

There are all kinds of ways you might load them dynamically.

For instance, they could even be part of a root game object which you’ll save as a prefab and load it and destroy it as needed.

You could do that with whole scenes.

You could split your world into a big matrix with large sized cells and only when the cells are within camera range, or getting close to it - load them.

I’d look through this post:

http://forum.unity3d.com/threads/41768-Seamless-world

thank you again! I'll try and reply back:)

–

@GuyTidhar well I put all my objects in a single empty game object and saved in a prefab (I have only an empty Terrain remaining), then deleted the object from Hierarchy and Instantiate the object (parent of everything) at the first Update function call. Held by a boolean of course to create it just once. like this: Still about 20 seconds (no change) I tried to call it from LateUpdate() , still same result. Well I have the scene almost empty at start takes loading same time as having every asset existing there! what it might be?

–