Unity-Technologies/UnityCsReference · error · LayoutException

No windows found in layout.

Error message

No windows found in layout.

What it means

LoadWindowLayout deserializes a layout file via InternalEditorUtility.LoadSerializedFileAndForget and expects at least one UnityObject (typically ContainerWindows). If the file is empty or yields zero objects, the layout is unusable and a LayoutException is thrown. This is the top-level guard against totally empty or fully unreadable layout files.

Source

Thrown at Editor/Mono/GUI/WindowLayout.cs:1325

                CloseWindows(flags.HasFlag(LoadWindowLayoutFlags.KeepMainWindow));

                ContainerWindow mainWindowToSetSize = null;
                ContainerWindow mainWindow = null;

                UnityObject[] remainingContainers = Resources.FindObjectsOfTypeAll(typeof(ContainerWindow));
                foreach (ContainerWindow window in remainingContainers)
                {
                    if (mainWindow == null && window.showMode == ShowMode.MainWindow)
                        mainWindow = window;
                    else
                        window.Close();
                }

                // Load data
                UnityObject[] loadedWindows = InternalEditorUtility.LoadSerializedFileAndForget(path);

                if (loadedWindows == null || loadedWindows.Length == 0)
                    throw new LayoutException("No windows found in layout.");

                List<UnityObject> newWindows = new List<UnityObject>();

                // At this point, unparented editor windows are neither desired nor desirable.
                // This can be caused by (legacy) serialization of FallbackEditorWindows or
                // other serialization hiccups (note that unparented editor windows should not exist in theory).
                // Same goes for empty DockAreas (no panes).  Leave them behind.
                for (int i = 0; i < loadedWindows.Length; i++)
                {
                    UnityObject o = loadedWindows[i];

                    if (o is EditorWindow editorWin)
                    {
                        if (!editorWin || !editorWin.m_Parent || !editorWin.m_Parent.window)
                        {
                            Console.WriteLine($"[LAYOUT] Removed un-parented EditorWindow while reading window layout" +
                                              $" window #{i}, type={o.GetType()} entityId={o.GetEntityId()}");
                            UnityObject.DestroyImmediate(editorWin, true);

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Delete or replace the bad layout file and fall back to the default layout.
  2. Verify the path passed to LoadWindowLayout actually contains a valid serialized layout.
  3. Restore the layout file from a backup or source control.
  4. If you ship a custom default layout, validate it loads in a clean editor before distribution.
Defensive patterns

Strategy: fallback

Validate before calling

// check file is non-trivial before loading
var fi = new FileInfo(path);
if (!fi.Exists || fi.Length == 0) return; // will trigger default-layout fallback

Try / catch

try { LoadWindowLayout(path); }
catch (LayoutException ex) when (ex.Message.Contains("No windows found"))
{ LoadDefaultWindowLayout(); }

Prevention

When it happens

Trigger: Loading a zero-byte or fully-corrupt .wlt file; a path that points to a file with no serialized windows; a deserialization failure that silently returned an empty array.

Common situations: A truncated layout file after a disk-full or crash during save; pointing LoadWindowLayout at a non-layout file; a permissions issue preventing deserialization.

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/234b744a66e9b145. Report an issue: GitHub.