private void DrawItem(Rect r, string guid) { FR2_Ref rf; if (!refs.TryGetValue(guid, out rf)) { return; } if (rf.depth == 1) //mode != Mode.Dependency && { Color c = GUI.color; GUI.color = Color.blue; GUI.DrawTexture(new Rect(r.x - 4f, r.y + 2f, 2f, 2f), EditorGUIUtility.whiteTexture); GUI.color = c; } rf.asset.Draw(r, false, FR2_Setting.GroupMode != FR2_RefDrawer.Mode.Folder, null); Rect drawR = r; drawR.x = drawR.x + drawR.width - 50f; // (groupDrawer.TreeNoScroll() ? 60f : 70f) ; drawR.width = 30; drawR.y += 1; drawR.height -= 2; if (GUI.Button(drawR, "X", EditorStyles.miniButton)) { FR2_Setting.RemoveIgnore(rf.asset.assetPath); } }
public static bool DrawSearchFilter() { int n = FILTERS.Length; var nCols = 4; int nRows = Mathf.CeilToInt(n / (float)nCols); var result = false; EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); { if (GUILayout.Button("All", EditorStyles.toolbarButton) && !FR2_Setting.IsIncludeAllType()) { FR2_Setting.IncludeAllType(); result = true; } if (GUILayout.Button("None", EditorStyles.toolbarButton) && FR2_Setting.GetExcludeType() != -1) { FR2_Setting.ExcludeAllType(); result = true; } } EditorGUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); for (var i = 0; i < nCols; i++) { GUILayout.BeginVertical(); for (var j = 0; j < nRows; j++) { int idx = i * nCols + j; if (idx >= n) { break; } bool s = !FR2_Setting.IsTypeExcluded(idx); bool s1 = GUILayout.Toggle(s, FILTERS[idx].name); if (s1 != s) { result = true; FR2_Setting.ToggleTypeExclude(idx); } } GUILayout.EndVertical(); if ((i + 1) * nCols >= n) { break; } } GUILayout.EndHorizontal(); return(result); }
//[MenuItem("Assets/FR2/Toggle Ignore", false, 19)] private static void Ignore() { Object[] actives = Selection.objects; for (var i = 0; i < actives.Length; i++) { string path = AssetDatabase.GetAssetPath(actives[i]); if (path.Equals(FR2_Cache.DEFAULT_CACHE_PATH)) { continue; } if (FR2_Setting.IgnoreAsset.Contains(path)) { FR2_Setting.RemoveIgnore(path); } else { FR2_Setting.AddIgnore(path); } } }
public static bool DrawSearchFilter() { var n = FILTERS.Length; var nCols = 4; var nRows = Mathf.CeilToInt(n / (float)nCols); var result = false; GUILayout.BeginHorizontal(); for (var i = 0; i < nCols; i++) { GUILayout.BeginVertical(); for (var j = 0; j < nRows; j++) { var idx = i * nCols + j; if (idx >= n) { break; } var s = !FR2_Setting.IsTypeExcluded(idx); var s1 = GUILayout.Toggle(s, FILTERS[idx].name); if (s1 != s) { result = true; FR2_Setting.ToggleTypeExclude(idx); } } GUILayout.EndVertical(); if ((i + 1) * nCols >= n) { break; } } GUILayout.EndHorizontal(); return(result); }
private void DrawGroup(Rect r, string id, int childCound) { GUI.Label(r, id, EditorStyles.boldLabel); if (childCound <= 1) { return; } Rect drawR = r; drawR.x = drawR.x + drawR.width - 50f; // (groupDrawer.TreeNoScroll() ? 60f : 70f) ; drawR.width = 30; drawR.y += 1; drawR.height -= 2; if (GUI.Button(drawR, "*X", EditorStyles.miniButton)) { List <FR2_Ref> lst = refs.Values.Where(x => x.group == id).ToList(); for (var i = 0; i < lst.Count; i++) { FR2_Setting.RemoveIgnore(lst[i].asset.assetPath); } } }
private void ApplyFilter() { dirty = false; if (refs == null) { return; } if (list == null) { list = new List <FR2_Ref>(); } else { list.Clear(); } int minScore = searchTerm.Length; string term1 = searchTerm; if (!caseSensitive) { term1 = term1.ToLower(); } string term2 = term1.Replace(" ", string.Empty); excludeCount = 0; foreach (KeyValuePair <string, FR2_Ref> item in refs) { FR2_Ref r = item.Value; if (r.depth == 0 && !FR2_Setting.ShowSelection) { continue; } if (FR2_Setting.IsTypeExcluded(r.type)) { excludeCount++; continue; //skip this one } if (!showSearch || string.IsNullOrEmpty(searchTerm)) { r.matchingScore = 0; list.Add(r); continue; } //calculate matching score string name1 = r.isSceneRef ? (r as FR2_SceneRef).sceneFullPath : r.asset.assetName; if (!caseSensitive) { name1 = name1.ToLower(); } string name2 = name1.Replace(" ", string.Empty); int score1 = FR2_Unity.StringMatch(term1, name1); int score2 = FR2_Unity.StringMatch(term2, name2); r.matchingScore = Mathf.Max(score1, score2); if (r.matchingScore > minScore) { list.Add(r); } } RefreshSort(); }
void ApplyFilter() { dirty = false; if (refs == null) { return; } if (list == null) { list = new List <FR2_Ref>(); } else { list.Clear(); } var minScore = searchTerm.Length; var term1 = searchTerm; if (!caseSensitive) { term1 = term1.ToLower(); } var term2 = term1.Replace(" ", string.Empty); excludeCount = 0; foreach (var item in refs) { var r = item.Value; if (r.depth == 0 && !FR2_Setting.ShowSelection) { continue; } if (FR2_Setting.IsTypeExcluded(r.type)) { excludeCount++; continue; //skip this one } if (!showSearch || string.IsNullOrEmpty(searchTerm)) { r.matchingScore = 0; list.Add(r); continue; } //calculate matching score var name1 = r.asset.assetName; if (!caseSensitive) { name1 = name1.ToLower(); } var name2 = name1.Replace(" ", string.Empty); var score1 = StringMatch(term1, name1); var score2 = StringMatch(term2, name2); r.matchingScore = Mathf.Max(score1, score2); if (r.matchingScore > minScore) { list.Add(r); } } RefreshSort(); }
// void OnActive private void RefreshView(CBParams assetList) { cacheAssetList = assetList; dirty = false; list = new List <FR2_Ref>(); refs = new Dictionary <string, FR2_Ref>(); dicIndex = new Dictionary <string, List <FR2_Ref> >(); if (assetList == null) { return; } int minScore = searchTerm.Length; string term1 = searchTerm; if (!caseSensitive) { term1 = term1.ToLower(); } string term2 = term1.Replace(" ", string.Empty); excludeCount = 0; for (var i = 0; i < assetList.Count; i++) { var lst = new List <FR2_Ref>(); for (var j = 0; j < assetList[i].Count; j++) { string guid = AssetDatabase.AssetPathToGUID(assetList[i][j]); if (string.IsNullOrEmpty(guid)) { continue; } if (refs.ContainsKey(guid)) { continue; } FR2_Asset asset = FR2_Cache.Api.Get(guid); if (asset == null) { continue; } var fr2 = new FR2_Ref(i, 0, asset, null); if (FR2_Setting.IsTypeExcluded(fr2.type)) { excludeCount++; continue; //skip this one } if (string.IsNullOrEmpty(searchTerm)) { fr2.matchingScore = 0; list.Add(fr2); lst.Add(fr2); refs.Add(guid, fr2); continue; } //calculate matching score string name1 = fr2.asset.assetName; if (!caseSensitive) { name1 = name1.ToLower(); } string name2 = name1.Replace(" ", string.Empty); int score1 = FR2_Unity.StringMatch(term1, name1); int score2 = FR2_Unity.StringMatch(term2, name2); fr2.matchingScore = Mathf.Max(score1, score2); if (fr2.matchingScore > minScore) { list.Add(fr2); lst.Add(fr2); refs.Add(guid, fr2); } } dicIndex.Add(i.ToString(), lst); } ResetGroup(); }
protected void DrawFooter() { GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(EditorStyles.toolbar); { Color color = GUI.contentColor; GUI.contentColor = EditorGUIUtility.isProSkin ? new Color(0.9f, 0.9f, 0.9f, 1f) : new Color(0.1f, 0.1f, 0.1f, 1f); if (FR2_Unity.DrawToggleToolbar(ref FR2_Setting.showSettings, Icon.icons.Setting, 21f)) { maskDirty(); if (FR2_Setting.showSettings) { showFilter = showIgnore = false; } } GUI.contentColor = color; bool v = checkNoticeFilter(); string content = !FR2_Setting.IsIncludeAllType() ? "*Filter" : "Filter"; if (v) { Color oc = GUI.backgroundColor; GUI.backgroundColor = Color.red; v = GUILayout.Toggle(showFilter, content, EditorStyles.toolbarButton, GUILayout.Width(50f)); GUI.backgroundColor = oc; } else { v = GUILayout.Toggle(showFilter, content, EditorStyles.toolbarButton, GUILayout.Width(50f)); } if (v != showFilter) { showFilter = v; if (showFilter) { FR2_Setting.showSettings = showIgnore = false; } } v = checkNoticeIgnore(); content = FR2_Setting.IgnoreAsset.Count > 0 ? "*Ignore" : "Ignore"; if (v) { Color oc = GUI.backgroundColor; GUI.backgroundColor = Color.red; v = GUILayout.Toggle(showIgnore, content, EditorStyles.toolbarButton, GUILayout.Width(50f)); GUI.backgroundColor = oc; } else { v = GUILayout.Toggle(showIgnore, content, EditorStyles.toolbarButton, GUILayout.Width(50f)); } // var i = GUILayout.Toggle(showIgnore, content, EditorStyles.toolbarButton, GUILayout.Width(50f)); if (v != showIgnore) { showIgnore = v; if (v) { showFilter = FR2_Setting.showSettings = false; } } bool ss = FR2_Setting.ShowSelection; v = GUILayout.Toggle(ss, "Selection", EditorStyles.toolbarButton, GUILayout.Width(60f)); if (v != ss) { FR2_Setting.ShowSelection = v; maskDirty(); } if (FR2_Selection.SelectionCount > 0) { if (GUILayout.Button("Commit Selection [" + FR2_Selection.SelectionCount + "]", EditorStyles.toolbarButton)) { FR2_Selection.Commit(); } if (GUILayout.Button("Clear Selection", EditorStyles.toolbarButton)) { FR2_Selection.ClearSelection(); } } GUILayout.FlexibleSpace(); if (!IsFocusingDuplicate && !IsFocusingGUIDs) { float o = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 42f; FR2_RefDrawer.Mode ov = FR2_Setting.GroupMode; var vv = (FR2_RefDrawer.Mode)EditorGUILayout.EnumPopup("Group", ov, GUILayout.Width(122f)); if (vv != ov) { FR2_Setting.GroupMode = vv; maskDirty(); } GUILayout.Space(4f); EditorGUIUtility.labelWidth = 30f; FR2_RefDrawer.Sort s = FR2_Setting.SortMode; var vvv = (FR2_RefDrawer.Sort)EditorGUILayout.EnumPopup("Sort", s, GUILayout.Width(100f)); if (vvv != s) { FR2_Setting.SortMode = vvv; RefreshSort(); } EditorGUIUtility.labelWidth = o; } } GUILayout.EndHorizontal(); }