private void OnSearchChanged(string searchString) { m_Selected = 0; m_SearchResults.Clear(); if (searchString.Length > 0) { string searchWithFilter = string.Format("{0} {1}", AssetFinderPrefs.GetTypeFilterString(), searchString); string[] searchFolders = AssetFinderPrefs.SearchFolders; bool hasSearchFolders = searchFolders != null && searchFolders.Length > 0; string[] assetGUIDs = hasSearchFolders ? AssetDatabase.FindAssets(searchWithFilter, searchFolders) : AssetDatabase.FindAssets(searchWithFilter); foreach (string GUID in assetGUIDs) { string assetPath = AssetDatabase.GUIDToAssetPath(GUID); if (!AssetDatabase.IsValidFolder(assetPath)) { if (AssetFinderPrefs.MaxResults != -1 && m_SearchResults.Count >= AssetFinderPrefs.MaxResults) { break; } m_SearchResults.Add(new SearchResult(assetPath, searchString)); } } } }
private void DrawOptions() { GUIStyle buttonStyle = new GUIStyle(EditorStyles.miniButton); buttonStyle.padding = new RectOffset(4, 4, 4, 4); Rect buttonRect = new Rect(position.width - OptionsButtonWidth - 5, 5, OptionsButtonWidth, 18); if (GUI.Button(buttonRect, new GUIContent(GetOptionsIcon(), "Options"), buttonStyle)) { AssetFinderPrefs prefs = new AssetFinderPrefs(OnPrefsChanged); Rect popupPosition = new Rect(position.width - prefs.GetWindowSize().x - 5, SpaceToResultsList, 0, 0); PopupWindow.Show(popupPosition, prefs); } }
private void OnGUI() { SearchResult.CreateStyles(); UpdateInputEvents(); UpdateSearch(); DrawOptions(); UpdateAssetList(); CheckClick(); if (m_SearchResults.Count > 0) { GUILayout.FlexibleSpace(); string filterWarning = AssetFinderPrefs.HasFilters() ? string.Format(" <color={0}>Filters are enabled.</color>", EditorGUIUtility.isProSkin ? "orange" : "#FF4500") : string.Empty; GUIStyle labelStyle = new GUIStyle(EditorStyles.label); labelStyle.richText = true; GUILayout.Label(string.Format("{0} assets found.{1}", m_SearchResults.Count, filterWarning), labelStyle); } }