{"record":{"id":"73ccadbc7961484d","repo":"Unity-Technologies/UnityCsReference","slug":"bindings-and-curves-must-be-of-equal-length","errorCode":null,"errorMessage":"bindings and curves must be of equal length","messagePattern":"bindings and curves must be of equal length","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Animation/AnimationUtility.bindings.cs","lineNumber":284,"sourceCode":"        [NativeMethod(ThrowsException = true)]\n        extern private static void Internal_SetObjectReferenceCurve([NotNull] AnimationClip clip, EditorCurveBinding binding, ObjectReferenceKeyframe[] keyframes, bool updateMuscleClip);\n\n        extern public static AnimationCurve GetEditorCurve([NotNull] AnimationClip clip, EditorCurveBinding binding);\n\n        public static void SetEditorCurve(AnimationClip clip, EditorCurveBinding binding, AnimationCurve curve)\n        {\n            Internal_SetEditorCurve(clip, binding, curve, true);\n            Internal_InvokeOnCurveWasModified(clip, binding, curve != null ? CurveModifiedType.CurveModified : CurveModifiedType.CurveDeleted);\n        }\n\n        public static void SetEditorCurves(AnimationClip clip, EditorCurveBinding[] bindings, AnimationCurve[] curves)\n        {\n            if (bindings == null)\n                throw new ArgumentNullException(nameof(bindings), $\"{nameof(bindings)} must be non-null\");\n            if (curves == null)\n                throw new ArgumentNullException(nameof(curves), $\"{nameof(curves)} must be non-null\");\n            if (bindings.Length != curves.Length)\n                throw new InvalidOperationException($\"{nameof(bindings)} and {nameof(curves)} must be of equal length\");\n\n            int length = bindings.Length;\n            for (int i = 0; i < length; i++)\n            {\n                SetEditorCurveNoSync(clip, bindings[i], curves[i]);\n            }\n            SyncEditorCurves(clip);\n\n            Internal_InvokeOnCurveWasModified(clip, new EditorCurveBinding(), AnimationUtility.CurveModifiedType.ClipModified);\n        }\n\n        internal static void SetEditorCurveNoSync(AnimationClip clip, EditorCurveBinding binding, AnimationCurve curve)\n        {\n            Internal_SetEditorCurve(clip, binding, curve, false);\n            Internal_InvokeOnCurveWasModified(clip, binding, curve != null ? CurveModifiedType.CurveModified : CurveModifiedType.CurveDeleted);\n        }\n\n        [NativeMethod(ThrowsException = true)]","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Animation/AnimationUtility.bindings.cs#L266-L302","documentation":"Thrown by AnimationUtility.SetEditorCurves when bindings.Length != curves.Length. The batch API iterates both in lockstep and calls SetEditorCurveNoSync per index; a mismatch would desync or index out of range, so it throws InvalidOperationException before the loop.","triggerScenarios":"Bindings built per-property and curves built per-clip, or vice versa. Filtering one array after building the other. Appending a curve for a new property but forgetting its binding.","commonSituations":"Rig migration where binding count changes. Editor tools that filter curves after constructing bindings. Copy-paste loops that increment one list conditionally.","solutions":["Assert bindings.Length == curves.Length with a context message at build time.","Construct both arrays in a single pass so they stay paired.","Run a length-equality check helper before every Set*Curves call.","If they legitimately differ, zip to the shorter and log the dropped entries."],"exampleFix":"// before\nAnimationUtility.SetEditorCurves(clip, bindings, curves);\n\n// after\nif (bindings.Length != curves.Length)\n    throw new InvalidOperationException($\"bindings({bindings.Length}) != curves({curves.Length}) on {clip.name}\");\nAnimationUtility.SetEditorCurves(clip, bindings, curves);","handlingStrategy":"validation","validationCode":"if (bindings.Length != curves.Length) throw new InvalidOperationException($\"bindings({bindings.Length}) != curves({curves.Length})\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Construct bindings and curves in a single paired pass.","Assert length equality with clip context for diagnostics.","Never filter one array without mirroring the other."],"tags":["animation","invalid-operation","editor","array-length","csharp"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}