Why after using Animation.AddClip(). Length of added clips always = 1

I am creating animationClip at runtime from json file, using KeyFrames and SetCurve.
After creation, I want to split the created animationClip into several smaller clips:

Animation anim;
AnimationClip createdAnimationClip;
…
anim.AddClip(createdAnimationClip,”name1”, 0, 100)
anim.AddClip(createdAnimationClip,”name2”, 100, 200);
anim.AddClip(createdAnimationClip,”name3”, 200, 500);

everything goes except well,
except one, all added clips in the anim clips array has length = 1 sec

and when I try to play the animation, only the first second is played, although there are many more frames

I can’t figure out if this is a bug or am I doing something wrong.

Unity version 2021.3.12

if anyone comes across this problem. my solution was additionally set frameRate on each added clip:

anim.AddClip(createdAnimationClip,”name1”, 0, 100);
    anim[name1].frameRate = 24;//set your frameRate

after that the length of the clip becomes correct.

3 Likes