Unity-Technologies/UnityCsReference · error · ArgumentException
poseCurve '{0}', rotationCurve '{1}', heightCurve '{2}' and
Error message
poseCurve '{0}', rotationCurve '{1}', heightCurve '{2}' and positionCurve '{3}' Length must be equals. What it means
Thrown by MuscleClipUtility.CalculateQualityCurves when the four quality-curve arrays (poseCurve, rotationCurve, heightCurve, positionCurve) do not all share the same Length. The native call expects equally-sized output buffers.
Source
Thrown at Editor/Mono/MuscleClipUtility.bindings.cs:47
internal struct QualityCurvesTime
{
public float fixedTime;
public float variableEndStart;
public float variableEndEnd;
public int q;
}
[NativeHeader("Editor/Src/Animation/MuscleClipQualityInfo.h")]
internal class MuscleClipUtility
{
[FreeFunction]
extern internal static MuscleClipQualityInfo GetMuscleClipQualityInfo([NotNull] AnimationClip clip, float startTime, float stopTime);
internal static void CalculateQualityCurves(AnimationClip clip, QualityCurvesTime time, Vector2[] poseCurve, Vector2[] rotationCurve, Vector2[] heightCurve, Vector2[] positionCurve)
{
if (poseCurve.Length != rotationCurve.Length || rotationCurve.Length != heightCurve.Length || heightCurve.Length != positionCurve.Length)
{
throw new ArgumentException(string.Format(
"poseCurve '{0}', rotationCurve '{1}', heightCurve '{2}' and positionCurve '{3}' Length must be equals.",
poseCurve.Length, rotationCurve.Length, heightCurve.Length, positionCurve.Length));
}
CalculateQualityCurves(clip, time.fixedTime, time.variableEndStart, time.variableEndEnd, time.q, poseCurve, rotationCurve, heightCurve, positionCurve);
}
[FreeFunction]
extern protected static void CalculateQualityCurves([NotNull] AnimationClip clip, float fixedTime, float variableEndStart, float variableEndEnd, int q, [Out] Vector2[] poseCurve, [Out] Vector2[] rotationCurve, [Out] Vector2[] heightCurve, [Out] Vector2[] positionCurve);
}
}
View on GitHub (pinned to 225b0fbdb5)
Solutions
- Allocate all four arrays to the same length before calling.
- Derive the length from a single source (e.g., the sampling resolution) and reuse it for all allocations.
- Add a precondition assert comparing the four lengths.
Example fix
// before var pose = new Vector2[n]; var rot = new Vector2[n + 1]; // mismatch // after int n = samples; var pose = new Vector2[n]; var rot = new Vector2[n]; var height = new Vector2[n]; var position = new Vector2[n]; MuscleClipUtility.CalculateQualityCurves(clip, time, pose, rot, height, position);
Defensive patterns
Strategy: validation
Validate before calling
bool EqualLen(Vector2[] a, Vector2[] b, Vector2[] c, Vector2[] d) =>
a.Length == b.Length && b.Length == c.Length && c.Length == d.Length; Prevention
- Allocate all four arrays from a single length source.
- Assert lengths match before the native call.
When it happens
Trigger: Calling CalculateQualityCurves with arrays of differing lengths, e.g., poseCurve.Length != rotationCurve.Length.
Common situations: Caller allocates the four arrays from different sources or with different sampling counts. Reusing partially-filled buffers. Off-by-one when computing required length from QualityCurvesTime.
Related errors
- Cannot add dependency on invalid ArtifactKey.
- The object to add cannot be null.
- The object to remove cannot be null.
- Platform GUID {platformGuid} is not a valid Unity build plat
- rendererIDs and results NativeArrays don't match in length.
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/16d2f40a7cdf5821.
Report an issue: GitHub.