This tool finds unreferenced assets in Unity project.
All code combined into one script for easier portability. So you can just copy-paste DependenciesHunter.cs to your project in any Editor folder.
At first, it calls
AssetDatabase.GetAllAssetPaths()
to form a map of all assets.
Then it uses:
AssetDatabase.GetDependencies
to find dependencies for each of those assets. As a result dependencies map is formed.
Then it simply finds all assets which are not presented as a dependency within this map. Such assets considered as unused if they aren't marked as to be ignored in this analysis (by a list of RegExp patterns).
To enable addressables usage uncomment the first line.
// #define HUNT_ADDRESSABLES
The tool has two ways to use it. Each has a menu option, and an editor window.
..click on "Tools/Dependencies Hunter" option which will open the "AllProjectAssetsReferencesWindow" window.
..select the assets and use a context menu option "Find References in Project". It will open the "SelectedAssetsReferencesWindow" window with the results.
Context Menu | Result Window |
---|---|
In the Analysis Settings foldout you can set files to be ignored by providing a list of RegExp patterns. You can also uncheck the 'Show Unreferenced Assets Only' toggle to view the list of all your project assets with their references number, files sizes etc.
Analysis Settings | Listing all Assets |
---|---|
- Through Unity's Package Manager. Use this as git url:
https://github.com/AlexeyPerov/Unity-Dependencies-Hunter.git#upm
. UPM support added via template. - Or you can just copy and paste file DependenciesHunter.cs inside Editor folder
Feel free to report bugs, request new features or to contribute to this project!
To find missing or empty references in your assets see Missing-References-Hunter.
To analyze your textures and atlases see Textures-Hunter.