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 | 使用人形上的所有可能的肌肉手柄来填充数组。 |