- Home /
Are the assets of referenced assets loaded into memory?
I have a gameobject that's used to instantiate prefabs. The prefabs this gameobject instantiates are referenced via serialized fields. The gameobjects to instantiate use textures.
Does Unity readily load into memory these assets the gameobjects use even if the gameobjects have not been instantiated yet (they are just referenced)?
I'm having memory usage issues now. T.T
Thanks! :D
Answer by Kryptos · Oct 03, 2012 at 02:41 PM
Yes they are loaded into memory.
In one of our project we had to write a special container to prevent this.
The basic idea is to put all assets in Resources folder. Then instead of referencing directly the prefab, you use the path (stored as a string). When you need to instantiate it, first use Resources.Load using the path.
Additionally, we had a custom inspector to help the designer set reference as usual (by drag and drop) and let the container store the path instead.
Thanks for the prompt response, my friend. We'll be implementing a solution similar to what you guys did. Thanks again! :D
well, it is true but for music/audio files, you can explicit choose if want to decompress on load or having them compressed in memory. In my observation it does the same as using the Resource call. (I could not find them in the Profiler $$anonymous$$emory)