@@ -155,6 +155,8 @@ void CreateEditor(VolumeComponent component, SerializedProperty property, int in
155155 else
156156 m_Editors [ index ] = editor ;
157157
158+ FilterEditorsBySearch ( ) ;
159+
158160 DocumentationUtils . TryGetHelpURL ( component . GetType ( ) , out string helpUrl ) ;
159161 helpUrl ??= string . Empty ;
160162 m_VolumeComponentHelpUrls [ editor ] = helpUrl ;
@@ -222,9 +224,22 @@ public void Clear()
222224 asset = null ;
223225 }
224226
227+ readonly HashSet < VolumeComponentEditor > m_CurrentSearchFilteredEditors = new ( ) ;
228+ void FilterEditorsBySearch ( )
229+ {
230+ m_CurrentSearchFilteredEditors . Clear ( ) ;
231+ if ( string . IsNullOrEmpty ( m_SearchString ) ) return ;
232+
233+ foreach ( var editor in m_Editors )
234+ {
235+ if ( MatchesSearchString ( editor . GetDisplayTitle ( ) . text ) )
236+ m_CurrentSearchFilteredEditors . Add ( editor ) ;
237+ }
238+ }
239+ bool EditorIsIncludedInCurrentSearch ( VolumeComponentEditor editor ) => string . IsNullOrEmpty ( m_SearchString ) || m_CurrentSearchFilteredEditors . Contains ( editor ) ;
225240 bool MatchesSearchString ( string title )
226241 {
227- return m_SearchString . Length == 0 || title . Contains ( m_SearchString , StringComparison . OrdinalIgnoreCase ) ;
242+ return string . IsNullOrEmpty ( m_SearchString ) || title . Contains ( m_SearchString , StringComparison . OrdinalIgnoreCase ) ;
228243 }
229244
230245 /// <summary>
@@ -263,7 +278,7 @@ bool ShouldDrawEditor(VolumeComponentEditor editor)
263278 {
264279 if ( ! editor . visible )
265280 return false ;
266- return MatchesSearchString ( editor . GetDisplayTitle ( ) . text ) ;
281+ return EditorIsIncludedInCurrentSearch ( editor ) ;
267282 }
268283
269284 void DrawEditor ( VolumeComponentEditor editor , int index = - 1 )
@@ -310,7 +325,11 @@ void DrawEditor(VolumeComponentEditor editor, int index = -1)
310325 {
311326 Rect searchRect = GUILayoutUtility . GetRect ( 50 , EditorGUIUtility . singleLineHeight ) ;
312327 searchRect . width -= 2 ;
313- m_SearchString = m_SearchField . OnGUI ( searchRect , m_SearchString ) ;
328+ using ( var check = new EditorGUI . ChangeCheckScope ( ) )
329+ {
330+ m_SearchString = m_SearchField . OnGUI ( searchRect , m_SearchString ) ;
331+ if ( check . changed ) FilterEditorsBySearch ( ) ;
332+ }
314333 GUILayout . Space ( 2 ) ;
315334
316335 EditorGUILayout . HelpBox (
@@ -346,7 +365,6 @@ void DrawEditor(VolumeComponentEditor editor, int index = -1)
346365
347366 for ( int i = 0 ; i < editors . Count ; i ++ )
348367 DrawEditor ( editors [ i ] ) ;
349-
350368 GUILayout . Space ( 8 ) ;
351369 }
352370 }
0 commit comments