Hi all,
We've observed an interesting bug, where an Atlas Material (and therefore the texture it referenced) was not being unloaded when invoking a Resources.UnloadUnusedAssets even though no objects remained which referred to the specified material.
After a fair bit of digging, we figured out that the material was added to the mChanged list inside UIPanel, and if the panel was never actually shown it was never removed. I added the following to UIPanel, which has resolved the issue:
void OnDestroy()
{
OnDisable();
mDrawCalls.Release();
mChanged.Release();
#if OLD_UNITY
mChildren.Release();
#endif
}
My best guess is that this is a deficiency in the Mono runtime (or some other part of Unity responsible for object management), where the internals of the BetterList are not being correctly cleared/Garbage Collected, even when the associated BetterList should be gone. On reading the code, I can see no reason that this should happen, however it undeniably was happening for us.
Cheers,
Jeremy