Version: 2021.3

MuscleHandle

struct in UnityEngine.Animations

切换到手册

描述

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