//----- params ----- //----- field ----- //----- property ----- //----- method ----- public static string[] OnWillSaveAssets(string[] paths) { if (CleanDirectoryUtility.Prefs.cleanOnSave) { List <DirectoryInfo> emptyDirs; CleanDirectoryUtility.FillEmptyDirList(out emptyDirs); if (emptyDirs != null && emptyDirs.Count > 0) { CleanDirectoryUtility.DeleteAllEmptyDirAndMeta(ref emptyDirs); Debug.Log("[Clean] Cleaned Empty Directories on Save"); } } return(paths); }
void OnGUI() { using (new EditorGUILayout.VerticalScope()) { using (new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button("Find Empty Dirs")) { CleanDirectoryUtility.FillEmptyDirList(out emptyDirectorys); if (!hasEmptyDirectorys) { ShowNotification(new GUIContent("No Empty Directory")); } else { RemoveNotification(); } } if (EditorLayoutTools.ColorButton("Delete All", hasEmptyDirectorys, Color.red)) { CleanDirectoryUtility.DeleteAllEmptyDirAndMeta(ref emptyDirectorys); ShowNotification(new GUIContent("Deleted All")); } } var cleanOnSave = CleanDirectoryUtility.Prefs.cleanOnSave; var toggle = GUILayout.Toggle(cleanOnSave, " Clean Empty Dirs Automatically On Save"); if (cleanOnSave != toggle) { CleanDirectoryUtility.Prefs.cleanOnSave = toggle; } GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); if (hasEmptyDirectorys) { using (var scrollViewScope = new EditorGUILayout.ScrollViewScope(scrollPosition)) { using (new EditorGUILayout.VerticalScope()) { var folderContent = new GUIContent(); foreach (var dirInfo in emptyDirectorys) { var assetObj = AssetDatabase.LoadAssetAtPath("Assets", typeof(UnityEngine.Object)); if (assetObj != null) { folderContent.text = CleanDirectoryUtility.GetRelativePath(dirInfo.FullName, Application.dataPath); GUILayout.Label(folderContent, GUILayout.Height(21f)); } } } scrollPosition = scrollViewScope.scrollPosition; } } } }