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

  1. Sanitise the Vector2 with float.IsFinite on both components before assigning.
  2. Trace the upstream math producing the value and guard the division (check denominator != 0).
  3. 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

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


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