Skip to content

AybarsBarut/Simple-Unity-Garbage-Finder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Simple Unity Garbage Finder This tool is a lightweight editor script for Unity designed to detect unused assets within your project. It helps clean up the project by identifying files that are not referenced by build scenes, the active scene, or Resources folders.

Features Deep Dependency Scanning: Considers Scenes in Build Settings, the "Resources" folder, and the currently open scene as "Root" objects. It then recursively scans all dependencies to ensure referenced assets are not marked as unused. Smart Folder Grouping: If every file within a specific directory is unused, the report will list the directory path with a [FOLDER] tag instead of listing every single file independently. This keeps the report clean and readable. Automatic Reporting: Generates a text file report in the project root directory and opens it automatically upon completion. Editor Only: The script is wrapped in #if UNITY_EDITOR directives, ensuring it does not affect your final build.

Installation Create a new C# script named UnusedAssetsFinder.cs in your Unity project. Paste the provided source code into the file. Create an empty GameObject in your scene (or select an existing one). Add the UnusedAssetsFinder component to the GameObject. Usage You can run the scanner in two ways: Method 1: Play Mode Since the script executes within the Start method, simply pressing Play in the Unity Editor will automatically trigger the scan. Method 2: Context Menu (Manual) To run the scan without entering Play Mode: Select the GameObject containing the UnusedAssetsFinder script. In the Inspector window, locate the component. Click the "three dots" icon (or gear icon) at the top-right of the component. Select Find Unused Assets from the menu. Output Upon completion, a file named UnusedAssets.txt will be created in your project's root directory (outside the Assets folder). The file will automatically open.

How It Works The algorithm follows this logic: Collection: It gathers all file paths located in the Assets/ directory. Root Identification: It identifies "Root" objects that must be kept: All scenes enabled in the Build Settings. Any asset located inside a "Resources" folder (or with "Resources" in its path). The currently active open scene. Dependency Check: It uses AssetDatabase.GetDependencies to find every script, material, texture, or object referenced by the Root objects. Comparison: It compares the list of all assets against the list of used assets. Grouping: It processes the unused list to group files into folders where applicable.

Disclaimer This tool lists assets that are statically unused. It cannot detect assets that are referenced dynamically via code (e.g., specific Addressables or asset bundles not standardly referenced). Always create a backup of your project before deleting any files based on this report.

About

A Simple Unity Garbage Finder to found unused content from any project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages