Find active references to an object

Is there a way to find a list of all references to a given object during runtime?

I’m trying to call Resources.UnloadUnusedAssets but unfortunately it doesn’t work for me which means that there are still active references to those assets somewhere. The assets AREN’T used in the scene so I’m probably keeping a reference of them somewhere in the code. However, I have no idea where that could be and reading through the code has proven useless so far. I need a way to find the potential references that might have been created and unlink them so that I can clean up the unused assets.

Cheers!

I don’t think there’s a built-in straightforward answer to this, but you should be able to create a relatively simple script to do this…

Have you checked these answers?

If you open the profiler and go to memory then click on simple and change to ‘detailed’ it’ll give you the option of showing all object references and where they’re referenced from. (you need to click ‘take sample’)

2 Likes

This is exactly what I needed. I thought that I would need to write a script for it like @BlackPete suggested but since the profiler can the referenced assets, this is even better! Thanks!