Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Bug InvalidCastException: Specified cast is not valid.

Discussion in 'Animation' started by freedom667, Sep 27, 2022.

  1. freedom667


    Sep 6, 2015
    I get this error When I put keyframe from sprite sheet. I don't know why

    Code (CSharp):
    1. InvalidCastException: Specified cast is not valid.
    2. UnityEditorInternal.AnimationRecording.AddKey (UnityEditorInternal.IAnimationRecordingState state, UnityEditor.EditorCurveBinding binding, System.Type type, System.Object previousValue, System.Object currentValue) (at /Users/bokken/buildslave/unity/build/Editor/Mono/Animation/AnimationWindow/AnimationRecording.cs:513)
    3. UnityEditorInternal.AnimationRecording.ProcessModifications (UnityEditorInternal.IAnimationRecordingState state, UnityEditor.UndoPropertyModification[] modifications) (at /Users/bokken/buildslave/unity/build/Editor/Mono/Animation/AnimationWindow/AnimationRecording.cs:420)
    4. UnityEditorInternal.AnimationRecording.Process (UnityEditorInternal.IAnimationRecordingState state, UnityEditor.UndoPropertyModification[] modifications) (at /Users/bokken/buildslave/unity/build/Editor/Mono/Animation/AnimationWindow/AnimationRecording.cs:455)
    5. UnityEditorInternal.AnimationWindowControl.ProcessAutoKey (UnityEditor.UndoPropertyModification[] modifications) (at /Users/bokken/buildslave/unity/build/Editor/Mono/Animation/AnimationWindow/AnimationWindowControl.cs:787)
    6. UnityEditorInternal.AnimationWindowControl.PostprocessAnimationRecordingModifications (UnityEditor.UndoPropertyModification[] modifications) (at /Users/bokken/buildslave/unity/build/Editor/Mono/Animation/AnimationWindow/AnimationWindowControl.cs:771)
    7. UnityEditor.Undo.InvokePostprocessModifications (UnityEditor.UndoPropertyModification[] modifications) (at /Users/bokken/buildslave/unity/build/Editor/Mono/Undo/Undo.bindings.cs:274)
    does anyone know the solution for this?

    Unity 2022.1.14f1
  2. freedom667


    Sep 6, 2015
    Won't anyone help? It's important
  3. Akarias


    Oct 28, 2021
    Hello ! This bug is still here ! I'm using Unity 2022.1.16f1 for a project with my students. The school installed this version. If you try to add a keyframe (in a animation) changing the sprite of a sprite renderer, it will give this error.

    The solution i found is to manually add a keyframe of type sprite renderer type. Then, if you try to modify the sprite again, the keyframe will add correctly. There is no sense ..

    I hope it's fixed in the other versions !