Created
July 3, 2019 02:51
-
-
Save beardordie/70789564148d9fee424229040b0f0a8f to your computer and use it in GitHub Desktop.
Unity Editor menu command to select all Empty folders in the project, easily clean them up or find abandoned or forgotten folders. From FPSSample
This file contains hidden or 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.Collections.Generic; | |
using UnityEditor; | |
public static class FindEmptyFolders | |
{ | |
[MenuItem("Assets/Find Empty Folders")] | |
static void OnFindEmptyFolders() | |
{ | |
var empties = new List<UnityEngine.Object>(); | |
foreach (var d in System.IO.Directory.GetDirectories("Assets", "*", System.IO.SearchOption.AllDirectories)) | |
{ | |
if (System.IO.Directory.GetFiles(d).Length == 0) | |
{ | |
empties.Add(AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(d)); | |
} | |
} | |
Selection.objects = empties.ToArray(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment