- Home /
How many instances of a Object are handled in Unity
On a GameObject, I have a list of AudioClips where many of the AudioClips are the same--will Unity load each instance into memory? Or will it know to just store one instance? Will it affect performance? How will memory management be handled in this case? The Profiler isn't showing a difference, but I'm not sure if it's meant for that.
Thanks
Answer by hiddenspring81 · May 29, 2013 at 08:01 PM
I can't say for certain if it's true for AudioClips, but for other types of assets (Meshes, Materials, etc), Unity will only store a single instance of the asset in memory, regardless of how many times that asset is referenced. If you modify that asset in some way, then Unity will create a new instance of that asset in memory.
For example, if I had two objects that referenced the same mesh in memory, that mesh would only be loaded once. If the UVs of the mesh were modified, then there would be two copies of that mesh in memory; a modified copy, and the original, unmodified copy. I'm sure the same is true for AudioClips. It doesn't matter if 1,000 objects reference the clip, or if only a single object references the clip; it's only loaded once.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
NAudio WMA to WAV Conversion Error 0 Answers
I have this out of memory issue when running my webgl game in iOS. 0 Answers
Optimization on list handling 2 Answers