Keyframe is generated after "SetCurve" call.

I am writing .anim file converter.
I have to add AnimationCurve to .anim file and save.

I call SetCurve to add scale key.

clip.SetCurve(newPath, typeof(Transform), "localScale.x", newCurve);
clip.SetCurve(newPath, typeof(Transform), "localScale.y", newCurve);
clip.SetCurve(newPath, typeof(Transform), "localScale.z", newCurve);

Inserted scale curve is ok.

But all “Rotation” key frame is generated like screen shot.

Before Call SetCurve “Animation Window”
2636450--185449--upload_2016-5-16_11-28-35.png

After Call SetCurve “Animation Window”

I think interpolated keyframe is showed in editor after “setcurve call”.

Can I prevent to generate roate keyframe after “SetCurve”?

I need your helps…

Nothing wrong with SetCurve, works fine for me.
Your error is something else

    AnimationClip clip;

    void OnGUI () {
        clip = (AnimationClip) EditorGUILayout.ObjectField( clip, typeof( AnimationClip ), false );

        if ( GUILayout.Button( "add a curve" ) ) {
            AnimationCurve curve = new AnimationCurve();
            Keyframe[] keys = new Keyframe[] { new Keyframe( 0, 1 ), new Keyframe( 1, 4 ) };
            curve.keys = keys;
            clip.SetCurve( "", typeof( Transform ), "localScale.x", curve );
            clip.SetCurve( "", typeof( Transform ), "localScale.y", curve );
            clip.SetCurve( "", typeof( Transform ), "localScale.z", curve );
        }
    }

thank you for your replay.

I resolve this.

Change clip.SetCurve to AnimationUtility.SetEdtorCurve(deprecated)

I spent 3days to figure out.