Tanoda
EmptyFolderUtility.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using System;
10using System.IO;
11using System.Linq;
12using UnityEditor;
13using UnityEngine;
14
15public static class EmptyFolderUtility {
16
17 [MenuItem("Assets/Delete Empty Folders")]
18 public static void DeleteEmptyFolders() {
19 string[] directories = Directory.GetDirectories("Assets", "*", SearchOption.AllDirectories);
20
21 foreach (var directory in directories) {
22 try {
23 if (!Directory.Exists(directory)) {
24 continue;
25 }
26
27 if (Directory.GetFiles(directory, "*", SearchOption.AllDirectories).Count(p => Path.GetExtension(p) != ".meta") > 0) {
28 continue;
29 }
30 } catch (Exception e) {
31 Debug.LogException(e);
32 }
33
34 try {
35 Directory.Delete(directory, recursive: true);
36 } catch (Exception e) {
37 Debug.LogError("Could not delete directory " + directory);
38 Debug.LogException(e);
39 }
40
41 }
42
43 AssetDatabase.Refresh();
44 }
45}
UnityEngine.Debug Debug
Definition: TanodaServer.cs:19