private static void loadEditorResources() { //Small logo string[] GUIDsmallLogo = AssetDatabase.FindAssets("AssetHunterLogoSmall t:texture2D", null); if (GUIDsmallLogo.Length >= 1) { m_window.m_UISmallLogo = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(GUIDsmallLogo[0]), typeof(Texture2D)) as Texture2D; #if UNITY_5_3_OR_NEWER m_window.titleContent.image = m_window.m_UISmallLogo; m_window.titleContent.text = "Asset Hunter"; #else m_window.title = "Asset Hunter"; #endif } //Warning string[] GUIDwarning = AssetDatabase.FindAssets("AssetHunterWarning t:texture2D", null); if (GUIDwarning.Length >= 1) { m_window.m_UIWarning = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(GUIDwarning[0]), typeof(Texture2D)) as Texture2D; } //wide logo string[] GUIDwideLogo = AssetDatabase.FindAssets("AssetHunterLogoWide t:texture2D", null); if (GUIDwideLogo.Length >= 1) { m_window.m_UIWideLogo = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(GUIDwideLogo[0]), typeof(Texture2D)) as Texture2D; } //Achievement string[] GUIDachievement = AssetDatabase.FindAssets("AssetHunterAchievementUnlocked t:texture2D", null); if (GUIDachievement.Length >= 1) { m_window.m_UIAchievementIcon = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(GUIDachievement[0]), typeof(Texture2D)) as Texture2D; } //SceneSelect string[] GUIDsceneSelect = AssetDatabase.FindAssets("AssetHunterSceneSelect t:texture2D", null); if (GUIDsceneSelect.Length >= 1) { m_window.m_UISceneSelect = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(GUIDsceneSelect[0]), typeof(Texture2D)) as Texture2D; } //FolderSelect string[] GUIDfolderSelect = AssetDatabase.FindAssets("AssetHunterFolderSelect t:texture2D", null); if (GUIDfolderSelect.Length >= 1) { m_window.m_UIFolderSelect = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(GUIDfolderSelect[0]), typeof(Texture2D)) as Texture2D; } //Settings string[] GUIDsettings = AssetDatabase.FindAssets("AssetHunterSettings t:texture2D", null); if (GUIDsettings.Length >= 1) { m_window.m_UISettings = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(GUIDsettings[0]), typeof(Texture2D)) as Texture2D; } string path = AssetHunterSettingsCreator.GetAssetPath(); AssetHunterMainWindow.Instance.settings = AssetDatabase.LoadAssetAtPath(path, typeof(ScriptableObject)) as AssetHunterSettings; }
internal static string GetAssetPath() { return(AssetHunterSettingsCreator.GetAssetPath()); }
private void OnGUI() { if (settings == null) { string path = AssetHunterSettingsCreator.GetAssetPath(); settings = AssetDatabase.LoadAssetAtPath(path, typeof(ScriptableObject)) as AssetHunterSettings; } scrollPos = EditorGUILayout.BeginScrollView(scrollPos); //Show all used types EditorGUILayout.BeginVertical(); string selectedPath = AssetDatabase.GetAssetPath(Selection.activeObject); //Make sure this window has focus to update contents AssetHunterSettingsWindow.Instance.Repaint(); EditorGUILayout.Separator(); GUILayout.Label("This is the settingswindow for Asset Hunter! " + System.Environment.NewLine + "-Choose folders, types or filenames to exclude when scanning the project", EditorStyles.boldLabel); GUILayout.Label("NB: If your project window is in \"Two column layout\" you need to select folders in the right hand side of that window", EditorStyles.miniLabel); GUILayout.Label("----------------------------------------------------------------------------", EditorStyles.boldLabel); //Force memorycleanup settings.m_MemoryCleanupActive = GUILayout.Toggle(settings.m_MemoryCleanupActive, "Force memory cleanup"); GUILayout.Label("Enable this if you experience memory crashes (Much slower)", EditorStyles.miniLabel); GUILayout.Label("----------------------------------------------------------------------------", EditorStyles.boldLabel); EditorGUILayout.Separator(); EditorGUILayout.Separator(); //Do we have a folder selected bool bFolderSelected = System.IO.Directory.Exists(selectedPath); //Is it valid bool validSelection = (bFolderSelected && settings.ValidateDirectory(Selection.activeObject)); //Select folder to exclude EditorGUILayout.BeginHorizontal(); GUI.color = (validSelection ? AssetHunterHelper.AH_BLUE : AssetHunterHelper.AH_GREY); if (GUILayout.Button(validSelection ? "Exclude selected folder" : "No valid folder selected", GUILayout.Width(btnMinWidthLarge))) { if (validSelection) { settings.ExcludeDirectory(Selection.activeObject); } } GUI.color = m_IntialGUIColor; if (validSelection) { GUILayout.Label(selectedPath, EditorStyles.miniBoldLabel); } GUI.color = m_IntialGUIColor; GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); //Select type to exclude EditorGUILayout.BeginHorizontal(); AssetHunterSerializableSystemType selectedType = null; if (Selection.activeObject) { selectedType = new AssetHunterSerializableSystemType(Selection.activeObject.GetType()); } //Do we have a valid asset selected validSelection = (selectedType != null && !bFolderSelected && settings.ValidateType(selectedType)); GUI.color = (validSelection ? AssetHunterHelper.AH_BLUE : AssetHunterHelper.AH_GREY); if (GUILayout.Button(validSelection ? "Exclude selected type" : "No valid type selected", GUILayout.Width(btnMinWidthLarge))) { if (validSelection) { settings.ExcludeType(selectedType); } } if (validSelection) { GUILayout.Label(selectedType.SystemType.ToString(), EditorStyles.miniBoldLabel); } GUI.color = m_IntialGUIColor; GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); //Exluded filename substrings EditorGUILayout.BeginHorizontal(); validSelection = !string.IsNullOrEmpty(m_excludeSubstringInput) && settings.ValidateSubstring(m_excludeSubstringInput); GUI.color = (validSelection ? AssetHunterHelper.AH_BLUE : AssetHunterHelper.AH_GREY); bool bHasHitEnter = false; Event e = Event.current; if (e.keyCode == KeyCode.Return) { bHasHitEnter = true; } if (bHasHitEnter || GUILayout.Button(validSelection ? "Exclude substring" : "No valid search string", GUILayout.Width(btnMinWidthLarge))) { if (validSelection) { settings.ExcludeSubstring(m_excludeSubstringInput); m_excludeSubstringInput = string.Empty; } } GUI.color = m_IntialGUIColor; m_excludeSubstringInput = GUILayout.TextField(m_excludeSubstringInput); //GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); if (validSelection) { GUILayout.Label(string.Format("Will exclude any asset with \"{0}\" in its path/name (might make asset hunter perform slower)", m_excludeSubstringInput)); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); GUILayout.Label("---------------------------Excluded Folders------------------------------", EditorStyles.boldLabel); if (settings.m_DirectoryExcludes.Count >= 1) { for (int i = settings.m_DirectoryExcludes.Count - 1; i >= 0; i--) { EditorGUILayout.BeginHorizontal(); GUI.color = AssetHunterHelper.AH_RED; if (GUILayout.Button("Delete", GUILayout.Width(btnMinWidthSmall))) { settings.RemoveDirectoryAtIndex(i); continue; } GUI.color = m_IntialGUIColor; EditorGUILayout.ObjectField(settings.m_DirectoryExcludes[i], typeof(UnityEngine.Object), false); EditorGUILayout.EndHorizontal(); } } else { EditorGUILayout.LabelField("No folders are currently excluded"); } EditorGUILayout.Separator(); GUILayout.Label("---------------------------Excluded Types--------------------------------", EditorStyles.boldLabel); if (settings.m_AssetTypeExcludes.Count >= 1) { for (int i = settings.m_AssetTypeExcludes.Count - 1; i >= 0; i--) { EditorGUILayout.BeginHorizontal(); GUI.color = AssetHunterHelper.AH_RED; if (GUILayout.Button("Delete", GUILayout.Width(btnMinWidthSmall))) { settings.RemoveTypeAtIndex(i); continue; } GUI.color = m_IntialGUIColor; GUILayout.Label(settings.m_AssetTypeExcludes[i].Name); EditorGUILayout.EndHorizontal(); } } else { EditorGUILayout.LabelField("No types are currently excluded"); } EditorGUILayout.Separator(); GUILayout.Label("---------------------------Excluded Substrings---------------------------", EditorStyles.boldLabel); if (settings.m_AssetSubstringExcludes.Count >= 1) { for (int i = settings.m_AssetSubstringExcludes.Count - 1; i >= 0; i--) { EditorGUILayout.BeginHorizontal(); GUI.color = AssetHunterHelper.AH_RED; if (GUILayout.Button("Delete", GUILayout.Width(btnMinWidthSmall))) { settings.RemoveSubstringAtIndex(i); continue; } GUI.color = m_IntialGUIColor; GUILayout.Label(string.Format("\"{0}\"", settings.m_AssetSubstringExcludes[i])); EditorGUILayout.EndHorizontal(); } } else { EditorGUILayout.LabelField("No substrings are currently excluded"); } EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); }
public static AssetHunterSettings LoadSettings() { string path = AssetHunterSettingsCreator.GetAssetPath(); return(AssetDatabase.LoadAssetAtPath(path, typeof(ScriptableObject)) as AssetHunterSettings); }