Character Mesh Switching With GameObject.SetActive Memory Question

I read this thread but I it is quite old and I am not sure if this is still how Unity works: gameObject.SetActive (false); stored in memory? - Questions & Answers - Unity Discussions

If I declare a game object variable and set it to a big prefab object called characterB. And then call the function characterB.SetActive(false), what happens… More specifically, if I had an array of 10 of those objects. What happens in Memory?

Does Unity store the entire objects of my complicated character meshes with multiple meshes, bones, textures, materials, animators, avatars, etc, all in memory, or just a reference to the address where to access it if I decide to set it active later?

They’re disabled in the scene and held in memory until you re-activate them. Destroy() them and release all references if you want the GC to pick them up.

Thanks

I know I am a few months late, but late thank you is better than no thank you.

1 Like