Hi folks,
Hopefully someone can enlighten me: If I add an AnimationClip to an object’s Animation component with AddClip(), then destroy the object, and later call FindObjectsOfType(typeof(UnityEngine.Object)), the animation clips are still present. As many times as I’ve called AddClip, I see that many references when I find objects. Any idea why these are hanging around? The animation clip is loaded in a prefab, there’s only ever one instance of it in my scene. I’m not instantiating any copies, and the animation components themselves are long gone.
thanks!
Im somewhat stumped by this as well. AnimationClips extend from Object. This means that Unity keeps a reference to it even after you’ve removed all of your own. In turn, that results in the garbage collector not purging it from memory. AudioClips have some of the same behavior. I’ve tried calling Resources.UnloadUnusedAssets(), but that is not removing the unused AnimationClips. Ive also noticed that some clips which I add via AddClip do not end up in the array returned from FindObjectOfType(typeof(AnimationClip)). This might be related to me not actually calling them anywhere in my scripts.