void RenderRows(WindowData windowData) { // todo show spinner until scene is loaded, if (FileResultRows.GetEntitiesCount() > 0) { windowData.ExpandFiles = EditorGUILayout.Foldout(windowData.ExpandFiles, $"Usages in Project: {FileResultRows.GetEntitiesCount()}"); } if (SearchArgMain.IsEmpty()) { return; } if (windowData.ExpandFiles && windowData.FindFrom == FindModeEnum.File) { foreach (var i in FileResultRows.Out(out var get1, out var get2, out _, out _)) { DrawRowFile(get1[i], get2[i], windowData); } } var sceneMessage = $"Usages in Scenes: {ScenePaths.GetEntitiesCount()}"; if (ScenePaths.GetEntitiesCount() > 0) { windowData.ExpandScenes = EditorGUILayout.Foldout(windowData.ExpandScenes, sceneMessage); } if (!windowData.ExpandScenes) { return; } if (windowData.ExpandScenes && windowData.FindFrom == FindModeEnum.Scene) { foreach (var(grp, indices) in SceneResultRows.Out(out _, out var get2, out _, out _) .GroupBy1(ResultComp.Instance)) { using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { var count = 0; foreach (var i in indices) { if (count++ == 0) { if (GUILayout.Button(get2[i].Label, windowData.Style.RowMainAssetBtn)) { if (windowData.Click.IsDoubleClick(grp.RootGo)) { // _selectionChangedByArrows = false; Selection.activeObject = grp.RootGo; } else { EditorGUIUtility.PingObject(grp.RootGo); } windowData.Click = new PrevClick(grp.RootGo); } } DrawRowScene(get2[i]); } } } } using (new GUILayout.HorizontalScope()) { GUILayout.Space(windowData.Style.SceneIndent1); using (new EditorGUILayout.VerticalScope()) { foreach (var i1 in ScenePaths.Out(out var get1, out var get2, out _)) { windowData.SceneFoldout.text = get1[i1].PathNicified; var details = get2[i1]; details.SearchRequested = details.Scene.isLoaded; details.SearchRequested = EditorGUILayout.Foldout(details.SearchRequested, windowData.SceneFoldout, EditorStyles.foldout); if (details.SearchRequested && details.Scene.isLoaded && !details.SearchDone) { var mainArg = SearchArgMain.GetSingle(); mainArg.Scene = SceneManager.GetSceneByPath(details.Scene.path); SearchUtils.InScene(mainArg, details.Scene); details.SearchDone = true; } if (!details.SearchRequested) { if (!details.Scene.isLoaded) { continue; } if (!details.WasOpened) { // to clean up on selection change AufCtx.World.NewEntityWith(out SceneToClose comp); comp.Scene = details.Scene; comp.ForceClose = true; } foreach (var row in SceneResultRows.Out(out _, out _, out var get3, out var entities)) { if (!get3[row].ScenePath.Eq(details.Path)) { continue; } entities[row].Destroy(); } details.SearchDone = false; } else { if (!details.Scene.isLoaded) { details.Scene = EditorSceneManager.OpenScene(details.Path, OpenSceneMode.Additive); // to clean up on selection change AufCtx.World.NewEntityWith(out SceneToClose comp); comp.Scene = details.Scene; comp.SelectionId = Globals <PersistentUndoRedoState> .Value.Id; #if UNITY_2019_1_OR_NEWER EditorSceneManager.SetSceneCullingMask(details.Scene, 0); #endif details.SearchRequested = true; // todo Scope component #if later if (details.Scene.isLoaded) { EditorSceneManager.CloseScene(details.Scene, false); } #endif } else if (SceneResultRows.IsEmpty()) { EditorGUILayout.LabelField("No in-scene dependencies found."); } else { using (new GUILayout.HorizontalScope()) { GUILayout.Space(windowData.Style.SceneIndent2); using (new EditorGUILayout.VerticalScope()) foreach (var(grp, indices) in SceneResultRows .Out(out var g1, out var g2, out var g3, out _) .GroupBy1(ResultComp.Instance)) { var any = false; foreach (var i3 in indices) { if (!g3[i3].ScenePath.Eq(details.Path)) { continue; } any = true; break; } if (!any) { continue; } using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { var count = 0; foreach (var i2 in indices) { if (!g3[i2].ScenePath.Eq(details.Path)) { continue; } if (count++ == 0) { Result comp = g1[i2]; if (GUILayout.Button(g2[i2].Label, windowData.Style.RowMainAssetBtn)) { if (windowData.Click.IsDoubleClick(grp.RootGo)) { // _selectionChangedByArrows = false; Selection.activeObject = comp.RootGo; } else { EditorGUIUtility.PingObject(comp.RootGo); } windowData.Click = new PrevClick(comp.RootGo); } } DrawRowScene(g2[i2]); } } } } } } } } } }