Unity-Technologies/UnityCsReference · error · InvalidOperationException

Cannot save to clip as there is nothing to save. The method

Error message

Cannot save to clip as there is nothing to save. The method TakeSnapshot() has not been called.

What it means

Thrown by GameObjectRecorder.SaveToClip(AnimationClip, float) when isRecording is false. The recorder only has data after TakeSnapshot has been called at least once; saving without snapshots would write an empty clip. The guard throws InvalidOperationException so the caller knows the recording session was never started.

Source

Thrown at Editor/Mono/Animation/GameObjectRecorder.bindings.cs:102

        extern public EditorCurveBinding[] GetBindings();

        // Recording.
        extern public void TakeSnapshot(float dt);
        extern public float currentTime { get; }
        extern public bool isRecording { get; }

        public void SaveToClip(AnimationClip clip)
        {
            SaveToClip(clip, 60.0f);
        }

        public void SaveToClip(AnimationClip clip, float fps)
        {
            if (fps <= Mathf.Epsilon)
                throw new ArgumentException("FPS can't be 0.0 or less");

            if (!isRecording)
                throw new InvalidOperationException("Cannot save to clip as there is nothing to save. The method TakeSnapshot() has not been called.");

            SaveToClipInternal(clip, fps, k_DefaultCurveFilterOptions);

            AnimationUtility.onCurveWasModified?.Invoke(clip, new EditorCurveBinding(), AnimationUtility.CurveModifiedType.ClipModified);
        }

        public void SaveToClip(AnimationClip clip, float fps, CurveFilterOptions filterOptions)
        {
            if (fps <= Mathf.Epsilon)
                throw new ArgumentException("FPS can't be 0.0 or less");

            if (filterOptions.keyframeReduction)
            {
                if (filterOptions.positionError < 0 || filterOptions.rotationError < 0 || filterOptions.scaleError < 0 || filterOptions.floatError < 0)
                    throw new ArgumentException("Allowed errors for keyframe reduction cannot be negative.");
            }

            if (!isRecording)

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Ensure at least one TakeSnapshot(dt) call occurs between Bind and SaveToClip.
  2. Check recorder.isRecording (or track a snapshot count) before saving.
  3. For deterministic bakes, loop TakeSnapshot over the desired frame range before SaveToClip.
  4. Call ResetRecording only after SaveToClip, not before.

Example fix

// before
recorder.Bind(transform);
recorder.SaveToClip(clip, 60f);

// after
recorder.Bind(transform);
for (int i = 0; i < frameCount; i++) recorder.TakeSnapshot(1f / 60f);
recorder.SaveToClip(clip, 60f);
Defensive patterns

Strategy: validation

Validate before calling

if (!recorder.isRecording) { Debug.LogError("Recorder has no samples; call TakeSnapshot first."); return; }

Prevention

When it happens

Trigger: Constructing a GameObjectRecorder, binding, then immediately calling SaveToClip without any TakeSnapshot. Calling TakeSnapshot after isRecording was already reset by ResetRecording or clip finalization. A delayed/async flow where snapshots were skipped due to an early return.

Common situations: Automated clip-baking tools that gate snapshots on a condition that never became true. Editor scripts that bind and save in the same callback without the per-frame snapshot step. Recorder reused across clips without restarting recording.

Related errors


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