用于 AnimationHumanStream 中的肌肉的句柄。
MuscleHandle 只能在 AnimationHumanStream 上使用,否则会抛出 InvalidOperationException
。
using UnityEngine; using UnityEngine.Animations; using UnityEngine.Playables;
public struct MuscleHandleExampleJob : IAnimationJob { public MuscleHandle muscleHandle;
public void ProcessRootMotion(AnimationStream stream) {} public void ProcessAnimation(AnimationStream stream) { AnimationHumanStream humanStream = stream.AsHuman();
// Get a muscle value. float muscleValue = humanStream.GetMuscle(muscleHandle);
// Set a muscle value. humanStream.SetMuscle(muscleHandle, muscleValue); } }
[RequireComponent(typeof(Animator))] public class MuscleHandleExample : MonoBehaviour { void Start() { var graph = PlayableGraph.Create(); var output = AnimationPlayableOutput.Create(graph, "output", GetComponent<Animator>());
var job = new MuscleHandleExampleJob(); job.muscleHandle = new MuscleHandle(HumanPartDof.LeftArm, ArmDof.HandDownUp);
var scriptPlayable = AnimationScriptPlayable.Create(graph, job); output.SetSourcePlayable(scriptPlayable);
graph.Evaluate(1.0f);
graph.Destroy(); } }
muscleHandleCount | 人形中的 DoF 部位总数。(只读) |
dof | 人体一小部分肌肉。(只读) |
humanPartDof | 人体一部分肌肉。(只读) |
name | 肌肉名称。(只读) |
MuscleHandle | 用于创造肌肉句柄的不同构造函数。 |
GetMuscleHandles | 用人形上所有可能的肌肉句柄填充数组。 |