Unity-Technologies/UnityCsReference · error · ArgumentOutOfRangeException

Must be greater than zero

Error message

Must be greater than zero

What it means

MakeBezierPoints requires at least one division segment to generate curve sample points. A division of zero or less would allocate an empty or invalid array and produce no geometry. The method allocates Vector3[division] and passes it to the native Internal_MakeBezierPoints, which expects at least one point.

Source

Thrown at Editor/Mono/Handles/Handles.cs:1818

        internal static void ShowSceneViewLabel(Vector3 pos, GUIContent label)
        {
            Handles.color = Color.white;
            Handles.zTest = UnityEngine.Rendering.CompareFunction.Always;
            GUIStyle style = "SC ViewAxisLabel";
            style.alignment = TextAnchor.MiddleLeft;
            style.fixedWidth = 0;
            Handles.BeginGUI();
            Rect rect = HandleUtility.WorldPointToSizedRect(pos, label, style);
            rect.x += 10;
            rect.y += 10;
            GUI.Label(rect, label, style);
            Handles.EndGUI();
        }

        public static Vector3[] MakeBezierPoints(Vector3 startPosition, Vector3 endPosition, Vector3 startTangent, Vector3 endTangent, int division)
        {
            if (division < 1)
                throw new ArgumentOutOfRangeException("division", "Must be greater than zero");
            var points = new Vector3[division];
            Internal_MakeBezierPoints(points.AsSpan(), startPosition, endPosition, startTangent, endTangent);

            return points;
        }

        public static void DrawTexture3DSDF(Texture texture,
            [DefaultValue("1.0f")] float stepScale = 1.0f,
            [DefaultValue("0.0f")] float surfaceOffset = 0.0f,
            [DefaultValue("null")] Gradient customColorRamp = null)
        {
            Vector3 localScale = new Vector3(matrix.GetColumn(0).magnitude, matrix.GetColumn(1).magnitude, matrix.GetColumn(2).magnitude);
            Texture3DPreview.PrepareSDFPreview(Texture3DPreview.Materials.SDF, texture, localScale, stepScale, surfaceOffset, customColorRamp);
            Texture3DPreview.Materials.SDF.SetPass(0);
            Graphics.DrawMeshNow(cubeMesh, matrix);
        }

        public static void DrawTexture3DSlice(Texture texture, Vector3 slicePositions,

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Clamp division to a minimum of 1 before calling: Math.Max(1, division).
  2. Add an early-return guard when start and end positions are nearly identical.

Example fix

// before
var pts = Handles.MakeBezierPoints(start, end, t1, t2, division);
// after
var pts = Handles.MakeBezierPoints(start, end, t1, t2, Math.Max(1, division));
Defensive patterns

Strategy: validation

Validate before calling

int safeDivision = Math.Max(1, division);
var pts = Handles.MakeBezierPoints(start, end, t1, t2, safeDivision);

Prevention

When it happens

Trigger: Calling Handles.MakeBezierPoints with division < 1, often from a distance-based or screen-size-based calculation that rounds down to zero when points are very close together.

Common situations: Dynamic curve rendering where the division count is computed from screen-space distance; when start and end overlap or are nearly identical the computed division can be zero.

Related errors


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