public UnityFolder(string folderPath, UnityFolder parentFolder, int depth) { this.folderPath = folderPath.Replace('\\', '/'); this.depth = depth; child_files = FindChildFiles(); child_folders = FindChildFolders(); //Create the object by giving its path. Then get the assetpreview. //Assets/New Folder-> folderName:New Folder }
private List <UnityFolder> FindChildFolders() { //GetDirectories will return all the subfolders in the given path. string[] dirs = Directory.GetDirectories(folderPath); List <UnityFolder> folders = new List <UnityFolder>(); foreach (var directory in dirs) { //Turn all directories into our 'UnityFolder' Object. UnityFolder newfolder = new UnityFolder(directory, this, depth + 1); folders.Add(newfolder); size += newfolder.size; } return(folders); }
private static void ShowFolderInfo(Rect r, Texture2D texture, Color col, string fileName) { if (r.height <= 16) { UnityFolder folder = Assets.FindFolder(fileName); if (folder == null) { return; } Rect rect = new Rect(r.x - 200, r.y, r.width + 200, r.height); DrawBox(rect); GUI.BeginGroup(r); GUI.color = col; if (texture != null) { GUI.DrawTexture(new Rect(new Vector2(r.width - 20, 0), new Vector2(16, 16)), texture); } if (showSizeInfo) { if (!EditorGUIUtility.isProSkin) { if (GUI.color == Color.white) { GUI.color = Color.black; } } if (folder.FileCount > 0 || folder.SubFolderCount > 0) { GUI.Label(new Rect(new Vector2(r.width - 100, 0), new Vector2(200, 16)), GetSizeFormat(folder.Size), EditorStyles.whiteMiniLabel); } else { GUI.Label(new Rect(new Vector2(r.width - 100, 0), new Vector2(200, 16)), "Empty!", EditorStyles.whiteMiniLabel); } } GUI.color = Color.white; GUI.EndGroup(); } }
public UnityFolder FindFolder(string path) { if (path.Equals(this.folderPath.Trim())) { return(this); } UnityFolder temp = null; for (int i = 0; i < child_folders.Count; i++) { temp = child_folders[i].FindFolder(path); if (temp != null) { return(temp); } } return(temp); }
private static void Drawer(Rect r, Texture2D texture, Color col, string fileName) { if (r.height > 16) { EditorApplication.RepaintProjectWindow(); GUI.BeginGroup(r); GUI.EndGroup(); GUI.color = col; GUI.DrawTexture(new Rect(new Vector2(r.x + 4, r.y + 4), new Vector2(r.width - 8, r.height - 8)), texture); GUI.color = Color.white; } else { UnityFolder folder = Assets.FindFolder(fileName); if (folder == null) { return; } GUI.color = col; GUI.BeginGroup(r); GUI.DrawTexture(new Rect(new Vector2(r.width - 20, 0), new Vector2(16, 16)), texture); GUI.color = Color.white; GUI.EndGroup(); } }
private static void Update() { EditorApplication.projectWindowItemOnGUI += ProjectViewEditor.EditorCallback(); Assets = new UnityFolder("Assets", null, 0); }
public UnityFile(string path, UnityFolder parentFolder) { extension = FindExtension(path); }