Asset Usage Detector - Find references to an asset/object [Open Source]

Thank a lot! This one is simply the best.

1 Like

Awesome, thanks you very much, can i right click a gameobject and have a menu find ?

i make a cheat

       [MenuItem("GameObject/FindReferenceInOpenScene",false,0)]
        public static void FastInit(MenuCommand menuCommand)
        {
            AssetUsageDetector window = GetWindow<AssetUsageDetector>();
            window.titleContent = new GUIContent("Asset Usage Detector");

            window.Show();

            window.assetToSearch = menuCommand.context as GameObject;

            if (window.assetToSearch == null)
            {
                window.errorMessage = "SELECT AN ASSET FIRST!";
            }
            else if (!EditorApplication.isPlaying && !window.AreScenesSaved())
            {
                // Don't start the search if at least one scene is currently dirty (not saved)
                window.errorMessage = "SAVE OPEN SCENES FIRST!";
            }
            else
            {
                window.errorMessage = string.Empty;
                window.currentPhase = Phase.Processing;

                if (!EditorApplication.isPlaying)
                    window.initialSceneSetup = EditorSceneManager.GetSceneManagerSetup(); // Get the scenes that are open right now
                else
                    window.initialSceneSetup = null;

                // Start searching
                window.ExecuteQuery();
            }
        }
1 Like

Do you mean like right clicking a prefab and selecting “Find References” from the context menu?

1 Like

right click a gameobject in scene and click FindSceRef in context menu, yes , i adding some code and it’s working. Thanks again !

Didn’t see the code, sorry :smile: Good job.

1 Like

Another thanks from me @yasirkula ! I’ve been meaning to write something like this as the “Find Reference …” is basically useless in my project, and this does exactly what I want it to.

1 Like

This is beautiful thanks!

1 Like

Fantastic. Only thing I don’t understand is why this isn’t build into Unity from the start.

Well done!

Lol, thanks!

Now available on Asset Store!

2 Likes

@yasirkula Very nice tool. Thanks for this contribution!

1 Like

Thank you sir, you save my time when ineed to find out where my asset use.

1 Like

What?! Free!? Let me hit that download Asset Usage Detector now before you change your mind!

One thing I think I will try to add, and you’re welcome to add also, is a referential rule enforcement scheme. I have folders for “THIS GAME” and “SHARED BETWEEN MY GAMES” and “OFFICIAL ACQUIRED” assets. Things in my SHARED folder are allowed to have references to OFFICIAL. Things in THIS GAME can refer to either one. But the other direction indicates bad practices. I don’t think I want to try to do this through AssetPostprocessor to enforce it 100% full time, but I do want to audit my projects on a regular basis.

1 Like

I think this use-case won’t apply to most projects, so I’ll skip it for now. But thank you for the suggestion!

What a great asset! Amazing this isn’t built in. Thank you!

1 Like

I love you right now.

Thanks :slight_smile:

1 Like

This is awesome, thank you! I have something similar implemented in python scripts, but its not very portable for the rest of our team.

Question, this asset seems to use a ton of memory, even when searching for one asset at depth 1. I measured up to 14GB of memory used to search my scenes in the project (there are maybe 30) for one asset (depth 1).

Is there any chance of reducing that memory usage?

That’s mainly caused by EditorUtility.CollectDependencies which loads all the objects in those scenes to the memory because it returns an Object[ ]. I think the only way to reduce the memory usage would be to cache these objects’ GUID’s on the first search and then reuse the cached data, as long as the scene doesn’t change.

As my current project grows and my use of ScriptableObjects grows I knew I’ll eventually need something like this and I’m super happy this already exists.

Fantastic awesome work!

Now I just need to figure out how to make this more friendly with ScriptableObjects when they are found inside my Behavior Designer trees (a great behavior tree plugin). You can see it of course but it doesn’t exactly tell you on which task the object is found.

In any case - invaluable stuff! Thank you!

1 Like