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

THANK YOU

you’re a life saver!

Just what I needed!

1 Like

@drambaldi I’ve found out that the Asset Store version of the plugin had a bug that caused the issue you are having. An update for the Asset Store version is under review, in the meantime I’d recommend you to update to the latest version from GitHub: Releases · yasirkula/UnityAssetUsageDetector · GitHub

Thank you so much @yasirkula , even after i buy some tool Finder with 15$, it’s not better than your free asset. It’s accurate and find what ever i want, just a little bit longer with huge project.

1 Like

Thanks for this amazing open source asset!

I am testing version 1.5.6 and everything work correctly with the cache!

I have always strange issue because I work on a legacy project that is up from 2016 and there is a lot of legacy-old code unremoved …

I have noticed this BUG, ONLY for one of my sprite (still investigating the issue to find the particlesystem that raise the error):

STEPS TO REPRODUCE

  • Search for a sprite with Search properties public and Non-public with Scenes in build settings
  • Select Include non-serializable fields and properties in search (slower search)
  • The Asset Usage detector fail with ERROR:
NullReferenceException: Do not create your own module instances, get them from a ParticleSystem instance
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.

Staktrace

rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.","NullReferenceException: Do not create your own module instances, get them from a ParticleSystem instance
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.","ParticleSystem+TextureSheetAnimationModule.get_frameOverTime() /Users/builduser/buildslave/unity/build/artifacts/generated/bindings_old/common/ParticleSystem/ParticleSystemBindings.gen.cs:2681
MonoMethod.Invoke() /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222
MonoMethod.Invoke() /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232
MonoProperty.GetValue() /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoProperty.cs:297
MonoProperty.GetValue() /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoProperty.cs:283
Utilities+<CreateGetter>c__AnonStorey0.<>m__0() Assets/Plugins/AssetUsageDetector/Editor/Utilities.cs:337
VariableGetterHolder.Get() Assets/Plugins/AssetUsageDetector/Editor/VariableGetter.cs:35
AssetUsageDetector.SearchFieldsAndPropertiesOf() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:1113
AssetUsageDetector.SearchObject() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:808
AssetUsageDetector.SearchFieldsAndPropertiesOf() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:1118
AssetUsageDetector.SearchComponent() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:918
AssetUsageDetector.SearchObject() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:789
AssetUsageDetector.SearchGameObject() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:850
AssetUsageDetector.SearchObject() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:787
AssetUsageDetector.BeginSearchObject() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:727
AssetUsageDetector.SearchGameObjectRecursively() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:712
AssetUsageDetector.SearchGameObjectRecursively() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:716
AssetUsageDetector.SearchGameObjectRecursively() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:716
AssetUsageDetector.SearchGameObjectRecursively() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:716
AssetUsageDetector.SearchGameObjectRecursively() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:716
AssetUsageDetector.SearchGameObjectRecursively() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:716
AssetUsageDetector.SearchGameObjectRecursively() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:716
AssetUsageDetector.SearchGameObjectRecursively() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:716
AssetUsageDetector.SearchGameObjectRecursively() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:716
AssetUsageDetector.SearchGameObjectRecursively() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:716
AssetUsageDetector.SearchScene() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:678
AssetUsageDetector.Run() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:544
Debug.LogException()
AssetUsageDetector.Run() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.cs:573
AssetUsageDetectorWindow.InitiateSearch() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs:529
AssetUsageDetectorWindow.OnGUI() Assets/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs:410
GUIUtility.ProcessEvent()"

Best Regards
Davide

1 Like

Apparently, this happens when there is a variable of type ParticleSystem.TextureSheetAnimationModule in a class. Although I can prevent this issue from occurring via a hacky tweak, it would have a negative impact in the overall search performance. So I won’t be implementing this fix. But we can let AssetUsageDetector continue the search despite this harmless error. It just a matter of changing VariableGetterHolder.Get function as follows:

public object Get( object obj )
{
    try
    {
        return getter( obj );
    }
    catch( Exception e )
    {
        Debug.LogException( e );
        return null;
    }
}

This change will be included in the next release, as well.

1 Like

@drambaldi The version with the fix (and numerous new features) is now released on GitHub: Releases · yasirkula/UnityAssetUsageDetector · GitHub. Asset Store version will be updated soon.

Hi @yasirkula , this is amazing. I’m not sure why Unity hasn’t developed their internal asset search (even their Find Reference in Scenes seems broken). Thanks a lot for this!

1 Like

I’m getting a stack overflow using this. And then my Unity crashes.
Also, the panel says “ERROR: Search was interrupted, check the logs” but the documentation doesn’t mention where the logs are stored (unless it’s referring to the Console/Unity logs).

Yes, it is Unity’s logs in Console. When does Unity crash? A few seconds after seeing that message? Are you using the latest version of the plugin? There has been a few bugfixes for this issue.

Yep, just download it from the Asset Store yesterday. Unity doesn’t crash it just freezes.
Here is an error log:

Can you add this function to line 1511 and see what it outputs: Debug.Log( assetPath + " " + dependencies *);*

Sorry but stack overflow + debug.log is not a good combo and ended up having to restart Unity. I think it happened on a terrain object or terrain data.

I’ve been trying to reproduce the issue on 2019.1 and 5.6 but couldn’t succeed. Which Unity version are you using? Are you searching while in Play mode? If possible, could you replace Debug.Log( assetPath + " " + dependencies _); with System.IO.File.AppendAllText( @"C:\Users\USERNAME\Desktop\log.txt", assetPath + " " + dependencies *+ "\n" );? Pinpointing the issue could really help here.*_

Sorry, I was using 2019.2.3f1. Searching in Edit mode. I already deleted a bunch of objects, so I can’t really be of much more help unfortunately.

1 Like

I’ve released a new version on GitHub. In addition to some other improvements, if an infinite loop is detected inside AssetHasAnyReference, plugin will now output some useful information to help debug the issue instead of raising a StackOverflowException.

1 Like

I really love this asset. It works better than find usages in some IDEs, where there is usually well established syntactic data model to exploit. Bravo.

If it were me, I would take down the promise that it will always be free. Anybody who gets it free now can keep getting it free even if you decide to charge new customers. Why limit your future options that way?

Anyway, very nice asset.

1 Like

Your support is much appreciated, thanks!

I will point out that it seems like it will find a reference to an asset if any asset with that same name has a reference. I fixed that by ensuring that the asset path was used as the object hash for an object that is also an asset.

I’ve created a test case as follows:

5424093--551814--test.png

Searching for references of the Test/Subfolder/Cube.prefab’s material only yields that prefab for me, not Test/Cube.prefab. Maybe in your case, the other asset with the same name had some other connection to the searched asset?

No. I verified there were no connections. When I went to where the tool said there was a connection, it was pointed toward the asset with the same name, not the one I was searching for.

Heres a more detailed version of the case:

  1. Two folders. Each has a PNG asset with the exact same name. The only difference is that one of them is 128x128 and the other is 512x512.
  2. Have a prefab with a reference to the 512x512 version.
  3. Search for everything under the first folder (the 128x128).
  4. It says it found a reference in the aforementioned asset.
  5. Click into the asset and see that the aforementioned reference is the 512x512 version of the image.