private void showUnusedAssets() { EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Collapse All", GUILayout.Width(200))) { foreach (ProjectFolderInfo folder in m_ProjectFolderList) { folder.FoldOut = false; } } if (GUILayout.Button("Expand All", GUILayout.Width(200))) { foreach (ProjectFolderInfo folder in m_ProjectFolderList) { folder.FoldOut = true; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); int indentLevel = 0; drawAssetFolderInfoRecursively(m_ProjectFolderList[0], indentLevel); if (m_assetMarkedForDeletion != null) { if (EditorUtility.DisplayDialog("Delete asset", "Are you sure you want to delete " + m_assetMarkedForDeletion.m_Name, "Yes", "No")) { m_assetMarkedForDeletion.Delete(m_unusedTypeDict); //Delete potential empty folders processDirectory(getSystemFolderPath(m_assetMarkedForDeletion.m_ParentPath)); m_assetMarkedForDeletion = null; } else { m_assetMarkedForDeletion = null; } } else if (m_folderMarkedForDeletion != null) { if (EditorUtility.DisplayDialog("Delete all child assets", "Are you sure you want to delete all " + m_folderMarkedForDeletion.GetAssetCountInChildren() + " child assets", "Yes", "No")) { List <AssetObjectInfo> objectsToDelete = new List <AssetObjectInfo>(); getObjectsMarkedForDeletion(m_folderMarkedForDeletion, ref objectsToDelete); deleteSelected(objectsToDelete); //Delete potential empty folders processDirectory(getSystemFolderPath(m_folderMarkedForDeletion.DirectoryName)); m_folderMarkedForDeletion = null; refreshUnusedAssets(); } else { m_folderMarkedForDeletion = null; } } }
/*private void OnUnusedScriptsUIUpdate() * { * if (m_UsedScriptList == null || m_UsedScriptList.Count <= 0) * return; * * scrollPos = EditorGUILayout.BeginScrollView(scrollPos); * EditorGUILayout.BeginVertical(); * * EditorGUILayout.LabelField("List of unused scripts", EditorStyles.boldLabel); * showUnusedScriptsUI(); * * EditorGUILayout.EndVertical(); * EditorGUILayout.EndScrollView(); * }*/ /*private void showUnusedScriptsUI() * { * * //TODO * //HERE IS A WAY TO FIND ALL CLASSES, Used, and Unused * //http://answers.unity3d.com/questions/30382/editor-assembly.html * * foreach (Type t in m_UnusedScriptList) * { * GUILayout.BeginHorizontal(); * MonoScript script = null; * * if (GUILayout.Button(t.ToString(), GUILayout.Width(btnMinWidth * 2 + 14))) * { * MonoScript[] scripts = (MonoScript[])Resources.FindObjectsOfTypeAll(typeof(MonoScript)); * foreach (MonoScript m in scripts) * { * if (m.GetClass() == t) * script = m; * } * Selection.activeObject = script; * } * GUILayout.EndHorizontal(); * } * }*/ #endregion private void showUnusedAssets() { EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Collapse All", GUILayout.Width(btnMinWidth))) { foreach (ProjectFolderInfo folder in m_ProjectFolderList) { folder.FoldOut = false; } } EditorGUILayout.Space(); if (GUILayout.Button("Expand All", GUILayout.Width(btnMinWidth))) { foreach (ProjectFolderInfo folder in m_ProjectFolderList) { folder.FoldOut = true; } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); int indentLevel = 0; drawAssetFolderInfoRecursively(m_ProjectFolderList[0], indentLevel); if (m_assetMarkedForDeletion != null) { if (EditorUtility.DisplayDialog("Delete asset", "Are you sure you want to delete " + m_assetMarkedForDeletion.m_Name, "Yes", "No")) { m_assetMarkedForDeletion.Delete(m_unusedTypeDict); //Delete potential empty folders int deleteCount = 0; deleteEmptyDirectories(getSystemFolderPath(m_assetMarkedForDeletion.m_ParentPath), ref deleteCount); m_assetMarkedForDeletion = null; } else { m_assetMarkedForDeletion = null; } } else if (m_folderMarkedForDeletion != null) { int dialogChoice = EditorUtility.DisplayDialogComplex( "Clean all assets in folder", "You can delete all assets below this folder, or you can choose to make a backup first. That will create a unitypackage with all your deleted assets, but it will be slow", "Delete all", "Backup and delete (Slow!)", "Cancel"); switch (dialogChoice) { //Normal delete case 0: deleteAllInFolder(m_folderMarkedForDeletion, false); break; //Delete with backup case 1: deleteAllInFolder(m_folderMarkedForDeletion, true); break; //Cancel case 2: m_folderMarkedForDeletion = null; break; default: Debug.LogError("Unrecognized option."); break; } } }