Hello,
I’ve got an external file that defines the motion across the time of characters.
I’d like to create animation clip with the API, I didn’t find any way to manipulate/create the time and position (maybe Transform property of the animation clip ?), like AnimationClip.CreateKeyframe(mytime, myTransform).
In fact, I want to reproduce the features offered by the Unity GUI for animation clip but with API.
Thanks by advance,
Lo
Not sure what you are trying to accomlish, but animation in unity is time based and not frame based, so there are no keyframe directly accessible to us. You can access time of clips trough animation states aka. something like this:
public Animation ani;
ani["nameOfAnimation"].time
or well
ani[ani.clip.name].time
If you are trying to create gui that controls the animation like a stop and play button, i suggest like written on this forum somewhere to use speed attribute of the clip.
if(GUILayout.Button("Play")) {
ani[ani.clip.name].speed = 1f;
}
if(GUILayout.Button("Stop")) {
ani[ani.clip.name].speed = 0f;
}
Using the ani.Stop() function also rewind the animation and this might not be what you want, certainly was not for me when i build my animation controller 
Why does Stop rewind when there is a Rewind function?
In fact,
I want to create an animation clip and define the position/rotation across the time but not with Unity GUI but with API during the loading of the scene.
The perfect way is to be able to do all the animation clip GUI by call of functions.
Example :
at t=0s
playerA is at 0,0,5 with animation = run
playerB is at 0,0,10 with animation = idle
at t= 2s
playerA is at 0,0,5 with animation = jump
playerB is at 0,0,10 with animation = walk
and so on…
I suppose the API exists because it’s possible with Unity interface…