{"record":{"id":"30604658be280ab6","repo":"Unity-Technologies/UnityCsReference","slug":"error-while-reading-window-layout-no-root-view-on","errorCode":null,"errorMessage":"Error while reading window layout: no root view on main window.","messagePattern":"Error while reading window layout: no root view on main window\\.","errorType":"exception","errorClass":"LayoutException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/GUI/WindowLayout.cs","lineNumber":1433,"sourceCode":"                    if (w is SceneHierarchyWindow || (w?.GetType() == HierarchyPreferences.HierarchyV2WindowType))\n                        HierarchyPreferences.EnsureCorrectHierarchyIsInUse(w);\n                }\n\n                if (mainWindowToSetSize)\n                {\n                    mainWindowToSetSize.position = mainWindowPosition;\n                }\n                // Always show main window before other windows. So that other windows can\n                // get their parent/owner.\n                if (mainWindow)\n                {\n                    // If at this point the mainWindow still doesn't have a rootView, it probably means we loaded a layout without a main window.\n                    // Delete the current mainWindow so that we can load back the previous layout otherwise every attemp at loading a layout will fail.\n                    if (mainWindow.rootView == null || !mainWindow.rootView)\n                    {\n                        mainWindow.Close();\n                        UnityObject.DestroyImmediate(mainWindow, true);\n                        throw new LayoutException(\"Error while reading window layout: no root view on main window.\");\n                    }\n\n                    mainWindow.Show(mainWindow.showMode, loadPosition: true, displayImmediately: true, setFocus: true);\n                    if (mainWindowToSetSize && mainWindow.maximized != mainWindowMaximized)\n                        mainWindow.ToggleMaximize();\n\n                    // Make sure to restore the save to layout flag when loading a layout from a file.\n                    if (flags.HasFlag(LoadWindowLayoutFlags.KeepMainWindow))\n                        mainWindow.m_DontSaveToLayout = false;\n                }\n                else if (!flags.HasFlag(LoadWindowLayoutFlags.NoMainWindowSupport))\n                {\n                    throw new LayoutException(\"Error while reading window layout: no main window found\");\n                }\n\n                // Show other windows\n                for (int i = 0; i < newWindows.Count; i++)\n                {","sourceCodeStart":1415,"sourceCodeEnd":1451,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/GUI/WindowLayout.cs#L1415-L1451","documentation":"After loading a layout, the editor requires the main window to have a valid rootView; if it is null the layout is considered missing a main window and is unrecoverable. The code destroys the broken main window and throws LayoutException so the caller can fall back to the previous/default layout. Without this, every subsequent load attempt would also fail.","triggerScenarios":"A layout file that serializes auxiliary windows but omits/not-wires the main window's rootView; a layout from a platform/build where the main window failed to serialize its root; corrupted main-window entry.","commonSituations":"Loading a layout saved on a different display setup or Unity version; a half-written layout file; editor startup with a stale default layout.","solutions":["Let Unity fall back to the previous/default layout (the throw is designed to trigger that recovery).","Replace the offending layout file with a known-good one.","Avoid manually editing the main window entry in layout files.","On persistent failures, delete the user's current layout settings (e.g. CurrentLayout.dwlt) to force regeneration."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { LoadWindowLayout(path, flags); }\ncatch (LayoutException ex) when (ex.Message.Contains(\"no root view on main window\"))\n{ LoadDefaultWindowLayout(); }","preventionTips":["Allow Unity to fall back to default layout when a load fails.","Do not hand-edit main-window entries in layout files.","Delete the stale CurrentLayout file if startup persistently fails."],"tags":["window-layout","serialization","invalid-state","editor","validation"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}