I have a .fbx file and I matched it with a Mecanim. During the run time I modify some of the joints rotations, and I wonder how I can save the whole animation on a file to include the modifications I did to the animation in the runtime.
Below is what I did but this saves the original animation not the modified one, so if anyone could please advise how I can save the animation including the modifications made in the runtime.
AnimationClip[] myclips = UnityEditor.AnimationUtility.GetAnimationClips (Mygameobject);
if (myclips .Length > 0) {
folder = EditorUtility.SaveFolderPanel ("Save my clip", "", "");
for (int i=0; i<myclips .Length; i++) {
AnimationClip myclip = myclips *;*
progress = ((float)myclips.Length) / (float)i;
EditorUtility.DisplayProgressBar (“Saving Animation”, myclip .name, progress);
ParseClip (myclip , i);
}
EditorUtility.ClearProgressBar ();
}
void ParseClip (AnimationClip clip, int clipnumber) {
AnimationClipCurveData[] cdataarray = AnimationUtility.GetAllCurves (clip, true);
int l = ((AnimationClipCurveData[])cdataarray).Length;
for(int x=0;x<l;x++)
{
AnimationClipCurveData cdata = cdataarray [x];
s.Append(cdata.propertyName+“.value”);
}
for (int i=0; i<cdataarray[0].curve.keys.Length; i++)
{
for(int x=0;x<l;x++)
{
AnimationClipCurveData cdata = cdataarray [x];
Keyframe kf = cdata.curve.keys*;*
s.Append(kf.value);
}
}
FileStream f = new FileStream (“My_file.txt”, FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter sw = new StreamWriter (f);
sw.Write (sb.ToString ());
sw.Close ();
f.Close ();
}