Unity-Technologies/UnityCsReference · error · ArgumentException
Invalid position: {value}
Error message
Invalid position: {value} What it means
ArgumentException thrown by the ContainerWindow.position setter when the assigned Rect fails View.IsValidViewRect. The window's pixel position/size on screen must be a valid view rectangle (finite, non-NaN, plausible dimensions); an invalid Rect is rejected before being forwarded to the native Internal_Position.
Source
Thrown at Editor/Mono/ContainerWindow.cs:103
internal void __internalAwake()
{
hideFlags = HideFlags.DontSave;
}
private void OnDestroy()
{
Internal_Destroy();
}
// Pixel-position on screen.
public Rect position
{
get => Internal_Position;
set
{
if (!View.IsValidViewRect(value))
throw new ArgumentException($"Invalid position: {value}");
Internal_Position = value;
}
}
internal ShowMode showMode => (ShowMode)m_ShowMode;
private string m_WindowID = null;
internal string windowID
{
get
{
if (String.IsNullOrEmpty(m_WindowID))
return GetWindowID();
return m_WindowID;
}
setView on GitHub (pinned to 225b0fbdb5)
Solutions
- Validate the Rect with View.IsValidViewRect before assigning.
- Sanitize computed rects (clamp sizes, reject NaN/Infinity via float.IsFinite) before use.
- Discard/reset corrupt layouts instead of applying invalid rects.
Example fix
// before
window.position = computedRect;
// after
if (View.IsValidViewRect(computedRect))
window.position = computedRect; Defensive patterns
Strategy: validation
Validate before calling
if (!View.IsValidViewRect(rect)) return; window.position = rect;
Type guard
static bool IsValidRect(Rect r) => View.IsValidViewRect(r) && float.IsFinite(r.x) && float.IsFinite(r.y) && float.IsFinite(r.width) && float.IsFinite(r.height);
Prevention
- Validate rects with View.IsValidViewRect before assigning.
- Reject NaN/Infinity in computed layout math.
- Discard corrupt layouts instead of applying them.
When it happens
Trigger: Assigning window.position a Rect containing NaN, infinity, or negative/extreme dimensions (e.g. computed from an uninitialized layout, a deserialized corrupt window layout, or arithmetic that produced NaN).
Common situations: Loading a corrupt editor window layout; scripts computing window rects from monitor DPI/scale that returned NaN; restoring window position across monitors with differing resolutions.
Related errors
- Cannot create more than one main window.
- Trying to create a second main window from layout when one a
- Unexpected resultBits Span length. The expected length of re
- Not a valid handle, has it been released already?
- GetInstallationForPath: Does not allow null editorPath
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/1c0dc719aa836e73.
Report an issue: GitHub.