- Home /
Do disabled gameobjects cause textures to load in RAM and/or GPU?
If I have a GameObject in a scene that is not active, or the attached mesh renderer is disabled, when I call Application.LoadLevel
, do the textures still get loaded in RAM and/or GPU buffers? I'm using Unity 5.
I searched for an answer but all I found was one older forum thread and a blog post that makes me think prior to Unity 3 they were not, but as of Unity 3 they might load "everything" now to avoid spikes/delays when you activate an object for the first time. Either way, it was all pretty old info, couldn't find anything current.
I'm not somewhere I can test right now, but couldn't you just try making a few dozen 2048x2048 images of static or something, then load them onto objects and hide them? That should be the difference between a little bit and significantly greater RA$$anonymous$$ usage in a scene (at least in a build, maybe?).
It should be easy enough to test a series of projects and/or scenes where one is all the objects without the textures, one is the same but with the objects hidden/disabled, one is with objects with textures and one is with textured objects hidden/disabled.
Excellent idea. To be honest I've never profiled with Unity, but I guess now is a good time to learn/start. I don't think I'd trust the tools/info/stats in editor mode, but I can probably just check task manager on a Windows build, if I make it obvious enough as you suggested.
Answer by hanger · May 18, 2015 at 05:43 AM
It's hard to say, especially since they just improved background loading. I hope they do load it all because that would really help things be less spiky.
Memory management used to be about calling Resources.UnloadUnusedAssets and praying. Now they have two more tools: Resources.UnloadAsset and AssetBundle.Unload. Look them over carefully. There are so many little incidental assets that I think UnloadUnusedAssets may still be the call you want to use the most. Nothing gets unloaded without one of those calls. (Though the gameobjects themselves also take more memory than you think and can be destroyed.)
You probably want to work in terms of prefabs for most things and levels if you need static geometry.
One major consideration is load times. Even if as much as possible happens in the background, there are other Awakes that take (relatively) a lot of time. uGUI has quite a few, like text layout and graphics compositing. Load times are so spiky that I haven't figured out how to do a load screen more complicated than a static image with a simple load bar. Some of it is going to be your own components' Awakes, but it's more trouble than it's worth to police them.
Accepted. Seems like the Unity devs (probably the only people that could answer this question -- inside knowledge) are more active in the forums. Guess I could try there, but I think I'll go ahead and be safe and not count on them not using resources.