diff --git a/src/UI/ObjectExplorer/SearchProvider.cs b/src/UI/ObjectExplorer/SearchProvider.cs index 2c11ac5..947a7a6 100644 --- a/src/UI/ObjectExplorer/SearchProvider.cs +++ b/src/UI/ObjectExplorer/SearchProvider.cs @@ -91,39 +91,39 @@ namespace UnityExplorer.UI.ObjectExplorer if (!string.IsNullOrEmpty(nameFilter) && !obj.name.ContainsIgnoreCase(nameFilter)) continue; + GameObject go = null; var type = obj.GetActualType(); - if (type == typeof(GameObject) || typeof(Component).IsAssignableFrom(type)) + + if (type == typeof(GameObject)) + go = obj.TryCast(); + else if (typeof(Component).IsAssignableFrom(type)) + go = obj.TryCast()?.gameObject; + + if (go) { - GameObject go = type == typeof(GameObject) - ? obj.TryCast() - : obj.TryCast()?.gameObject; + // hide unityexplorer objects + if (go.transform.root.name == "ExplorerCanvas") + continue; - if (go) + if (shouldFilterGOs) { - // hide unityexplorer objects - if (go.transform.root.name == "ExplorerCanvas") - continue; - - if (shouldFilterGOs) + // scene check + if (sceneFilter != SceneFilter.Any) { - // scene check - if (sceneFilter != SceneFilter.Any) - { - if (!Filter(go.scene, sceneFilter)) - continue; - } + if (!Filter(go.scene, sceneFilter)) + continue; + } - if (childFilter != ChildFilter.Any) - { - if (!go) - continue; + if (childFilter != ChildFilter.Any) + { + if (!go) + continue; - // root object check (no parent) - if (childFilter == ChildFilter.HasParent && !go.transform.parent) - continue; - else if (childFilter == ChildFilter.RootObject && go.transform.parent) - continue; - } + // root object check (no parent) + if (childFilter == ChildFilter.HasParent && !go.transform.parent) + continue; + else if (childFilter == ChildFilter.RootObject && go.transform.parent) + continue; } } }