Question by
LuizBeenoculus · Jun 27, 2018 at 08:20 PM ·
animationeditoreditor-scriptingbones
Applying values from an animationClip to bones of a skinnedMesh via code?
Hello guys!
I'm creating a custom editor and I need to get all the values of an animationClip in the first keyframe of the animation and apply those values to the respective bones of a skinnedMesh (it already has the rig).
I was able to get AnimationClip values through:
var allbindlings = AnimationUtility.GetCurveBindings(animClip);
foreach(var bind in allbindlings)
{
var keyframes = AnimationUtility.GetObjectReferenceCurve(animClip,bind);
if (keyframes!=null)
{
Debug.Log( bind.path + "/" + bind.propertyName +", keys" + keyframes.Length );
}
else
{
var curves = AnimationUtility.GetEditorCurve(animClip,bind);
string s = null;
for(var i = 0; i<curves.length; i++)
{
if (s!=null) s+="-";
s+= "(" + curves[i].time + ":" + curves[i].value +")";
}
Debug.Log(bind.propertyName + " " + bind.type + " " + s);
}
}
But I do not know now how to apply these data to the bones of a SkinnedMesh!
Someone know how to do that?
Comment