示例#1
0
        private void DrawDeleteFolderButton(AH_TreeviewElement folder)
        {
            if (multiColumnHeader.ShowMode != AH_MultiColumnHeader.AssetShowMode.Unused)
            {
                return;
            }

            string     description = "Delete unused assets from folder";
            GUIContent content     = new GUIContent("Delete " + (AH_Utils.GetSizeAsString(folder.GetFileSizeRecursively(AH_MultiColumnHeader.AssetShowMode.Unused))), description);
            GUIStyle   style       = new GUIStyle(GUI.skin.button);

            DrawDeleteFolderButton(content, folder, style, description, "Do you want to delete all unused assets from:" + Environment.NewLine + folder.RelativePath, GUILayout.Width(160), GUILayout.Height(32));
        }
        private void drawDeleteAssetsButton()
        {
            if (multiColumnHeader.ShowMode != AH_MultiColumnHeader.AssetShowMode.Unused)
            {
                return;
            }

            long combinedSize = 0;

            foreach (var item in selection)
            {
                combinedSize += item.FileSize;
            }
            if (GUILayout.Button("Delete " + (AH_Utils.GetSizeAsString(combinedSize)), GUILayout.Width(160), GUILayout.Height(32)))
            {
                deleteUnusedAssets();
            }
        }
示例#3
0
        private bool checkEmptyFolder(string dataPath)
        {
            if (dataPath.EndsWith(".git", StringComparison.InvariantCultureIgnoreCase))
            {
                return(false);
            }

            string[] files         = System.IO.Directory.GetFiles(dataPath);
            bool     hasValidAsset = false;

            for (int i = 0; i < files.Length; i++)
            {
                string relativePath;
                string assetID;
                AH_Utils.GetRelativePathAndAssetID(files[i], out relativePath, out assetID);

                //This folder has a valid asset inside
                if (!string.IsNullOrEmpty(assetID))
                {
                    hasValidAsset = true;
                    break;
                }
            }

            string[] folders = System.IO.Directory.GetDirectories(dataPath);
            bool     hasFolderWithContents = false;

            for (int i = 0; i < folders.Length; i++)
            {
                bool folderIsEmpty = checkEmptyFolder(folders[i]);
                if (!folderIsEmpty)
                {
                    hasFolderWithContents = true;
                }
                else
                {
                    Debug.Log("AH: Deleting empty folder " + folders[i]);
                    FileUtil.DeleteFileOrDirectory(folders[i]);
                }
            }

            return(!hasValidAsset && !hasFolderWithContents);
        }
        private static void runUpgradeTest()
        {
            //Check if we have old asset hunter installed already
            VersionUpgraderReady = getOldSettings().Length > 0;
            AH_PreProcessor.AddDefineSymbols(AH_PreProcessor.DefineHasOldVersion, VersionUpgraderReady);

            //Make sure we haven't chosen NOT to import
            if (EditorPrefs.HasKey(prefKey))
            {
                if (AH_Utils.IntToBool(EditorPrefs.GetInt(prefKey)) == true)
                {
                    return;
                }
            }

            if(VersionUpgraderReady)
                EditorUtility.DisplayDialog("Old Asset Hunter settings found", "To transfer old settings open 'Window->Asset Hunter Pro->Transfer Settings'", "Ok");

            EditorPrefs.SetInt(prefKey, 1);
        }
示例#5
0
        private string drawSettingsFolder(string title, string path, string defaultVal)
        {
            string validPath = path;
            string newPath   = "";

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Select", GUILayout.ExpandWidth(false)))
            {
                newPath = EditorUtility.OpenFolderPanel("Select folder", path, "");
            }

            if (newPath != "")
            {
                validPath = newPath;
            }

            GUIContent content = new GUIContent(title + ": " + AH_Utils.ShrinkPathMiddle(validPath, 44), title + " is saved at " + validPath);

            GUILayout.Label(content, (defaultVal != path) ? EditorStyles.boldLabel : EditorStyles.label);
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            return(validPath);
        }
示例#6
0
        private void doHeader()
        {
            AH_WindowStyler.DrawGlobalHeader(m_window, AH_WindowStyler.clr_Pink, "ASSET HUNTER PRO", true);
            EditorGUILayout.BeginHorizontal();

            bool infoLoaded = (buildInfoManager != null && buildInfoManager.HasSelection);

            if (infoLoaded)
            {
                GUIContent RefreshGUIContent = new GUIContent(guiContentRefresh);
                Color      origColor         = GUI.color;
                if (buildInfoManager.ProjectDirty)
                {
                    GUI.color = AH_WindowStyler.clr_lBlue;
                    RefreshGUIContent.tooltip = String.Format("{0}{1}", RefreshGUIContent.tooltip, " (Project has changed which means that treeview is out of date)");
                }

                if (doSelectionButton(RefreshGUIContent))// GUILayout.Button(content, GUILayout.MaxWidth(32), GUILayout.Height(18)))
                {
                    RefreshBuildLog();
                }

                GUI.color = origColor;
            }


            if (doSelectionButton(guiContentLoadBuildInfo))
            {
                openBuildInfoSelector();
            }
            EditorGUI.BeginDisabledGroup(!EditorBuildSettings.scenes.Any(val => val.enabled == true)); //Disable the generate btn if there are no enabled scenes in buildsettings
            if (doSelectionButton(guiContentGenerateBuildInfo))
            {
                generateBuildInfo();
            }
            EditorGUI.EndDisabledGroup();
            if (doSelectionButton(guiContentSettings))
            {
                AH_SettingsWindow.Init(true);
            }

            /*if (doSelectionButton(guiContentSceneUsage))
             *  AH_SceneReferenceWindow.Init();*/
            //Only avaliable in 2018
#if UNITY_2018_1_OR_NEWER
            if (infoLoaded && doSelectionButton(guiContentBuildReport))
            {
                AH_BuildReportWindow.Init();
            }
#endif

#if AH_HAS_OLD_INSTALLED
            //Transfer settings to PRO
            GUIContent TransferSettingsContent = new GUIContent("Transfer Settings", "Transfer your settings from old Asset Hunter into PRO");
            if (AH_VersionUpgrader.VersionUpgraderReady && GUILayout.Button(TransferSettingsContent, GUILayout.MaxHeight(18)))
            {
                AH_VersionUpgrader.RunUpgrade();
            }
#endif

            if (infoLoaded && m_TreeView.GetCombinedUnusedSize() > 0)
            {
                string sizeAsString = AH_Utils.GetSizeAsString(m_TreeView.GetCombinedUnusedSize());

                GUIContent instancedGUIContent = new GUIContent(guiContentDeleteAll);
                instancedGUIContent.tooltip = string.Format(instancedGUIContent.tooltip, sizeAsString);
                if (AH_SettingsManager.Instance.HideButtonText)
                {
                    instancedGUIContent.text = null;
                }

                GUIStyle btnStyle = "button";
                GUIStyle newStyle = new GUIStyle(btnStyle);
                newStyle.normal.textColor = AH_WindowStyler.clr_Pink;

                m_TreeView.DrawDeleteAllButton(instancedGUIContent, newStyle, GUILayout.MaxHeight(AH_SettingsManager.Instance.HideButtonText ? btnMaxHeight * 2f : btnMaxHeight));
            }

            GUILayout.FlexibleSpace();
            GUILayout.Space(20);

            if (m_TreeView != null)
            {
                m_TreeView.AssetSelectionToolBarGUI();
            }

            if (doSelectionButton(guiContentReadme))
            {
                Heureka_PackageDataManagerEditor.SelectReadme();
                if (AH_EditorData.Instance.Documentation != null)
                {
                    AssetDatabase.OpenAsset(AH_EditorData.Instance.Documentation);
                }
            }

            EditorGUILayout.EndHorizontal();
        }
 internal string GetSelectedBuildSize()
 {
     return(AH_Utils.GetSizeAsString((long)chosenBuildInfo.TotalSize));
 }
示例#8
0
 private string GetFormattedItemShort(string identifier, int charCount)
 {
     return(AH_Utils.ShrinkPathEnd(GetFormattedItem(identifier), charCount));
 }