Small utility to delete empty folder from the Unity project.
Based from a script in Unity3D College
Open the utility at Window > Tools > Clean Empty Folders
.
It will scan all the folders in your project and delete empty folders.
You can install this package using OpenUPM's command line tool:
openupm add dev.bullrich.folder-cleaner
-
Navigate to the
Packages
directory of your project. -
Adjust the project manifest file
manifest.json
in a text editor.- Ensure
https://package.openupm.com
is part ofscopedRegistries
.- Ensure
dev.bullrich
is part ofscopes
.
- Ensure
- Add
dev.bullrich.folder-cleaner
todependencies
, stating the latest version.
A minimal example ends up looking like this. Please note that the version
X.Y.Z
stated here is to be replaced with the latest released version which is currently.
{ "scopedRegistries": [ { "name": "package.openupm.com", "url": "https://package.openupm.com", "scopes": [ "dev.bullrich" ] } ], "dependencies": { "dev.bullrich.folder-cleaner": "X.Y.Z" } }
- Ensure
-
Switch back to the Unity software and wait for it to finish importing the added package.
If you want the log to list every directory that will be scanned you can add the Scripting Define Symbol
FOLDER_CLEANER_VERBOSE
to your project and it be more verbose when running.
There is a unit test to ensure that there are no empty directories in the project.
If you want to add this test to your project you can add it following this steps:
-
Navigate to the
Packages
directory of your project. -
Adjust the project manifest file
manifest.json
in a text editor.- Ensure
dev.bullrich.folder-cleaner
is part oftestables
.
A minimal example ends up looking like this.
{ "scopedRegistries": [ ... ], "testables": [ "dev.bullrich.folder-cleaner" ], "dependencies": { ... } }
- Ensure
-
As noted in the official Unity documentation:
NOTE: You may need to re-import the package, because the test framework doesn't always immediately pick up changes to the
testables
attribute.- Within the Unity software's
Project
window expand thePackages
node. - Right-click on the
Folder Cleaner
child node and chooseReimport
. - Wait for the Unity software to finish re-importing the package.
- Within the Unity software's
-
In the Unity software select
Main Menu -> Window -> Test Runner
. -
Within the Test Runner window click on the
EditMode
tab and the clickRun All
button. -
If all the tests pass then the installation was successful.