Unity-Technologies/UnityCsReference · error · LayoutException

No parent view

Error message

No parent view

What it means

During the 'maximize main view' / un-maximize flow, the code expects to find a parent view to reparent the docked pane into; if no parent view exists it throws LayoutException. This guards against an inconsistent host-view hierarchy that would otherwise leave the window in a broken docking state.

Source

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

                    newDockArea.RemoveTab(oldWindow);
                    UnityObject.DestroyImmediate(oldWindow);

                    foreach (UnityObject o in newWindows)
                    {
                        EditorWindow curWin = o as EditorWindow;
                        if (curWin != null)
                            curWin.MakeParentsSettingsMatchMe();
                    }

                    parent.Initialize(parent.window);

                    //If parent window had to be resized, call this to make sure new size gets propagated
                    parent.position = parent.position;
                    oldRoot.Reflow();
                }
                else
                {
                    throw new LayoutException("No parent view");
                }

                // Kill the maximizedMainView
                UnityObject.DestroyImmediate(maximizedHostView);

                win.Focus();

                var gv = win as GameView;
                if (gv != null)
                    gv.m_Parent.EnableVSync(gv.vSyncEnabled);
            }
            catch (Exception ex)
            {
                Debug.Log("Maximization failed: " + ex);
                ResetAllLayouts();
            }
        }

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Ensure the window still has a valid parent container before triggering maximize/un-maximize.
  2. Reset the layout to default to restore a consistent view hierarchy.
  3. Avoid programmatically reparenting host views; use the documented docking API.
  4. If scripting maximize, check that maximizedHostView has a parent before invoking the operation.
Defensive patterns

Strategy: validation

Validate before calling

// confirm the host view has a parent before maximize/un-maximize
if (hostView?.parent == null) return;

Try / catch

try { /* maximize routine */ }
catch (LayoutException ex) when (ex.Message == "No parent view")
{ /* reset to default layout */ }

Prevention

When it happens

Trigger: Calling the maximize/un-maximize routine when the current host view has no parent (e.g. it is already the root container); a layout state where the GameView/SceneView was orphaned by a previous failed dock operation; programmatic window manipulation that detached the pane from its container.

Common situations: Editor extension that moves windows between containers; a docking bug that orphaned a pane; recovering from a previously aborted layout load.

Related errors


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