Created
May 13, 2019 12:12
-
-
Save baba-s/6f518a6ef99368bb7bf05c5f4a394683 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using UnityEditor; | |
public static class EmptyFolderDeleter | |
{ | |
[MenuItem( "Tools/Delete Empty Folder" )] | |
private static void Delete() | |
{ | |
DoDelete( "Assets" ); | |
AssetDatabase.Refresh(); | |
} | |
private static void DoDelete( string path ) | |
{ | |
foreach ( var dir in Directory.GetDirectories( path ) ) | |
{ | |
DoDelete( dir ); | |
var files = Directory.GetFiles( dir ); | |
if ( files.Length != 0 ) continue; | |
var dirs = Directory.GetDirectories( dir ); | |
if ( dirs.Length != 0 ) continue; | |
AssetDatabase.DeleteAsset( dir ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment