本文整理汇总了C#中Spine.Apply方法的典型用法代码示例。如果您正苦于以下问题:C# Spine.Apply方法的具体用法?C# Spine.Apply怎么用?C# Spine.Apply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spine
的用法示例。
在下文中一共展示了Spine.Apply方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BakeBone
static void BakeBone (Bone bone, Spine.Animation animation, AnimationClip clip) {
Skeleton skeleton = bone.Skeleton;
bool inheritRotation = bone.Data.InheritRotation;
skeleton.SetToSetupPose();
animation.Apply(skeleton, 0, 0, true, null);
skeleton.UpdateWorldTransform();
float duration = animation.Duration;
AnimationCurve curve = new AnimationCurve();
List<Keyframe> keys = new List<Keyframe>();
float rotation = bone.RotationIK;
if (!inheritRotation)
rotation = GetUninheritedRotation(bone);
keys.Add(new Keyframe(0, rotation, 0, 0));
int listIndex = 1;
float r = rotation;
int steps = Mathf.CeilToInt(duration / bakeIncrement);
float currentTime = 0;
float lastTime = 0;
float angle = rotation;
for (int i = 1; i <= steps; i++) {
currentTime += bakeIncrement;
if (i == steps)
currentTime = duration;
animation.Apply(skeleton, lastTime, currentTime, true, null);
skeleton.UpdateWorldTransform();
int pIndex = listIndex - 1;
Keyframe pk = keys[pIndex];
pk = keys[pIndex];
if (inheritRotation)
rotation = bone.RotationIK;
else {
rotation = GetUninheritedRotation(bone);
}
angle += Mathf.DeltaAngle(angle, rotation);
r = angle;
float rOut = (r - pk.value) / (currentTime - pk.time);
pk.outTangent = rOut;
keys.Add(new Keyframe(currentTime, r, rOut, 0));
keys[pIndex] = pk;
listIndex++;
lastTime = currentTime;
}
curve = EnsureCurveKeyCount(new AnimationCurve(keys.ToArray()));
string path = GetPath(bone.Data);
string propertyName = "localEulerAnglesBaked";
EditorCurveBinding xBind = EditorCurveBinding.FloatCurve(path, typeof(Transform), propertyName + ".x");
AnimationUtility.SetEditorCurve(clip, xBind, new AnimationCurve());
EditorCurveBinding yBind = EditorCurveBinding.FloatCurve(path, typeof(Transform), propertyName + ".y");
AnimationUtility.SetEditorCurve(clip, yBind, new AnimationCurve());
EditorCurveBinding zBind = EditorCurveBinding.FloatCurve(path, typeof(Transform), propertyName + ".z");
AnimationUtility.SetEditorCurve(clip, zBind, curve);
}