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); }
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 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(); }