/// <summary> /// draw the Ignore button /// </summary> /// <param name="buttonText">What should the button read</param> /// <param name="ignoredList">The current list of Ignores this is supposed to be appended to</param> /// <param name="identifier">The unique identifier of the Ignore</param> /// <param name="optionalLegibleIdentifier">Humanly legible identifier</param> protected void drawButton(bool validSelected, string buttonText, AH_IgnoreList ignoredList, string identifier, string optionalLegibleIdentifier = "") { bool btnUsable = validSelected && !ignoredList.ExistsInList(identifier); EditorGUILayout.BeginHorizontal(); EditorGUI.BeginDisabledGroup(!btnUsable); if (GUILayout.Button(buttonText, GUILayout.Width(150)) && btnUsable) { IgnoreCallback(Selection.activeObject, identifier); } EditorGUI.EndDisabledGroup(); //Select the proper string to write on label string label = (!btnUsable) ? ((validSelected) ? "Already Ignored" : "Invalid selection") : (string.IsNullOrEmpty(optionalLegibleIdentifier) ? identifier : optionalLegibleIdentifier); GUIContent content = new GUIContent(label, EditorGUIUtility.IconContent((!btnUsable) ? ((validSelected) ? "d_lightOff" : "d_orangeLight") : "d_greenLight").image); GUILayout.Label(content, GUILayout.MaxHeight(16)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); }
private void Init() { ignoredListPathEndsWith = new AH_IgnoreList(new IgnoredEventActionPathEndsWith(0, onIgnoreButtonDown), InitialValueIgnoredPathEndsWith, PrefsIgnoredPathEndsWith); ignoredListTypes = new AH_ExclusionTypeList(new IgnoredEventActionType(1, onIgnoreButtonDown), InitialValueIgnoredTypes, PrefsIgnoredTypes); ignoredListFolders = new AH_IgnoreList(new IgnoredEventActionFolder(2, onIgnoreButtonDown), InitialValueIgnoredFolders, PrefsIgnoredFolders); ignoredListFiles = new AH_IgnoreList(new IgnoredEventActionFile(3, onIgnoreButtonDown), InitialValueIgnoredFiles, PrefsIgnoredFiles); ignoredListExtensions = new AH_IgnoreList(new IgnoredEventActionExtension(4, onIgnoreButtonDown), InitialValueIgnoredExtensions, PrefsIgnoredExtensions); //Todo subscribing to these 5 times, means that we might refresh buildinfo 5 times when reseting...We might be able to batch that somehow ignoredListPathEndsWith.ListUpdatedEvent += OnListUpdatedEvent; ignoredListTypes.ListUpdatedEvent += OnListUpdatedEvent; ignoredListFolders.ListUpdatedEvent += OnListUpdatedEvent; ignoredListFiles.ListUpdatedEvent += OnListUpdatedEvent; ignoredListExtensions.ListUpdatedEvent += OnListUpdatedEvent; }
//Check if the currectly selected asset if excludable as path ending public void DrawIgnored(AH_IgnoreList ignoredList) { if (!hasValidSelectionObject()) { return; } string path; bool isMain; bool isFolder; getObjectInfo(out path, out isMain, out isFolder); drawButton((isMain && isFolder), "Ignore folder ending", ignoredList, getIdentifier(path)); }
//Check if the currectly selected asset if excludable as folder public void DrawIgnored(AH_IgnoreList ignoredList) { if (!hasValidSelectionObject()) { return; } string path; bool isMain; bool isFolder; getObjectInfo(out path, out isMain, out isFolder); string assetGUID = getIdentifier(path); drawButton((isMain && isFolder), "Ignore folder", ignoredList, assetGUID, GetFormattedItemShort(assetGUID, 40)); }
//Check if the currectly selected asset if excludable as type public void DrawIgnored(AH_IgnoreList ignoredList) { if (!hasValidSelectionObject()) { return; } string path; bool isMain; bool isFolder; getObjectInfo(out path, out isMain, out isFolder); Type assetType; drawButton((isMain && !isFolder), "Ignore Type", ignoredList, getIdentifier(path, out assetType), assetType != null ? assetType.ToString() : ""); }
//Check if the currectly selected asset if excludable as file extension public void DrawIgnored(AH_IgnoreList ignoredList) { if (!hasValidSelectionObject()) { return; } string path; bool isMain; bool isFolder; getObjectInfo(out path, out isMain, out isFolder); //if (isMain) { string extension; bool validElement = (pathContainsValidElement(path, out extension)); drawButton(isMain && validElement, "Ignore file extension", ignoredList, extension); } }