- Home /
Create a Sprite Animation in Code
I am trying to construct an Animation clip in C#
AnimationClip animClip = new AnimationClip();
Keyframe[] ks;
ks = new Keyframe[4];
ks[0] = new Keyframe(0f, 0f);
ks[1] = new Keyframe(1f, 1f);
ks[2] = new Keyframe(2f, 2f);
ks[3] = new Keyframe(3f, 3f);
AnimationCurve _curve = new AnimationCurve(ks);
animClip.SetCurve("TestAnimation2", typeof(SpriteRenderer), "Sprite", _curve);
animClip.wrapMode = WrapMode.Loop;
game_object.AddComponent ("Animation");
game_object.animation.AddClip (animClip, "AnimationCurve7");
game_object.animation.Play("AnimationCurve7");
The above works? however :
How do I add a different sprite to each keyframe?
Comment
Your answer