Unity-Technologies/UnityCsReference · error · ArgumentException
Invalid minSize: {value}
Error message
Invalid minSize: {value} What it means
The EditorWindow.minSize setter validates the supplied Vector2 through View.IsValidViewSize, which rejects any component that is NaN or Infinity. Normal finite values (including zero or negative) pass, so the throw is specifically about non-finite math, not about unrealistic window sizes.
Source
Thrown at Editor/Mono/EditorWindow.cs:1162
[VisibleToOtherModules("UnityEditor.UIBuilderModule")]
internal void RepaintImmediately()
{
if (m_Parent && m_Parent.actualView == this)
m_Parent.RepaintImmediately();
}
// the minimum size of this window
public Vector2 minSize
{
get
{
return m_MinSize;
}
set
{
if (!View.IsValidViewSize(value))
throw new ArgumentException($"Invalid minSize: {value}");
m_MinSize = value;
MakeParentsSettingsMatchMe();
}
}
// the maximum size of this window
public Vector2 maxSize
{
get
{
return m_MaxSize;
}
set
{
if (!View.IsValidViewSize(value))
throw new ArgumentException($"Invalid minSize: {value}");
View on GitHub (pinned to 225b0fbdb5)
Solutions
- Sanitise the Vector2 with float.IsFinite on both components before assigning.
- Trace the upstream math producing the value and guard the division (check denominator != 0).
- Reset the corrupted layout (delete Library/current.max-default layout) if the value comes from deserialisation.
Example fix
// before window.minSize = new Vector2(width / dpi, height / dpi); // after Vector2 SizeOr(float v, float f) => float.IsFinite(v) ? new Vector2(v, v) : new Vector2(f, f); window.minSize = float.IsFinite(dpi) ? new Vector2(width / dpi, height / dpi) : new Vector2(100, 100);
Defensive patterns
Strategy: validation
Validate before calling
static Vector2 SafeMin(Vector2 v, Vector2 fallback) =>
float.IsFinite(v.x) && float.IsFinite(v.y) ? v : fallback;
window.minSize = SafeMin(computed, new Vector2(100, 100)); Type guard
static bool IsValidViewSize(Vector2 v) => float.IsFinite(v.x) && float.IsFinite(v.y);
Prevention
- Always sanitise DPI- or content-derived sizes with float.IsFinite.
- Guard division denominators before computing sizes.
- Discard corrupt layout files (Library/current.max-default) when sizes look like NaN.
When it happens
Trigger: Assigning window.minSize from a computation that produced NaN (0/0) or Infinity (division by zero) — e.g. computing size from a float division without guarding the denominator, or deserialising corrupt layout data.
Common situations: Dynamically sizing a window based on screen DPI or content where a denominator can be zero. Layout deserialization after a layout-file corruption. Editor scripts that scale minSize by a factor sourced from an unset preferences value.
Related errors
- Invalid minimum size: {min}
- Invalid maximum size: {max}
- TierSettings.renderingPath must be actual rendering path (no
- Filters must be declared in pairs { "FileType", "FileExtensi
- The source path cannot be empty.
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/8945ea9e0b6c35e6.
Report an issue: GitHub.