@@ -285,12 +285,14 @@ internal static List<GameObject> GetSceneReferencesToObject(Object obj)
285
285
var instanceID = obj . GetInstanceID ( ) ;
286
286
var idFormat = "ref:{0}:" ;
287
287
288
+ var sceneHierarchy = GetPropertyReflection ( sceneHierarchyWindow , "sceneHierarchy" , isPublic : true ) ;
289
+ var previousSearchFilter = sceneHierarchy . GetType ( ) . GetField ( "m_SearchFilter" , System . Reflection . BindingFlags . NonPublic | System . Reflection . BindingFlags . Instance ) . GetValue ( sceneHierarchy ) ;
290
+
288
291
// Set the search filter to find all references in the scene to the given object
289
292
var setSearchFilterMethod = sceneHierarchyWindowType . GetMethod ( "SetSearchFilter" , System . Reflection . BindingFlags . NonPublic | System . Reflection . BindingFlags . Instance ) ;
290
293
setSearchFilterMethod . Invoke ( sceneHierarchyWindow , new object [ ] { string . Format ( idFormat , instanceID ) , SearchableEditorWindow . SearchMode . All , true , false } ) ;
291
294
292
295
// Get objects from list of instance IDs of currently visible objects
293
- var sceneHierarchy = GetPropertyReflection ( sceneHierarchyWindow , "sceneHierarchy" , isPublic : true ) ;
294
296
var treeView = GetPropertyReflection ( sceneHierarchy , "treeView" , isPublic : false ) ;
295
297
var data = GetPropertyReflection ( treeView , "data" , isPublic : true ) ;
296
298
var getRows = data . GetType ( ) . GetMethod ( "GetRows" ) ;
@@ -308,7 +310,7 @@ internal static List<GameObject> GetSceneReferencesToObject(Object obj)
308
310
}
309
311
310
312
// remove the filter when done
311
- setSearchFilterMethod . Invoke ( sceneHierarchyWindow , new object [ ] { "" , SearchableEditorWindow . SearchMode . Name , true , false } ) ;
313
+ setSearchFilterMethod . Invoke ( sceneHierarchyWindow , new object [ ] { previousSearchFilter , SearchableEditorWindow . SearchMode . Name , true , false } ) ;
312
314
return sceneObjects ;
313
315
}
314
316
0 commit comments