Class RigBuilder
RigBuilder is the root component that holds the Rigs that create an Animation Rigging hierarchy. Its purpose is to create the PlayableGraph that will be used in the associated Animator component to animate a character with constraints.
Inherited Members
Namespace: UnityEngine.Animations.Rigging
Syntax
[RequireComponent(typeof(Animator))]
[DisallowMultipleComponent]
[ExecuteInEditMode]
[AddComponentMenu("Animation Rigging/Setup/Rig Builder")]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.animation.rigging@1.3/manual/RiggingWorkflow.html#rig-builder-component")]
public class RigBuilder : MonoBehaviour, IAnimationWindowPreview, IRigEffectorHolder
Fields
onAddRigBuilder
Notification callback that is sent whenever a RigBuilder calls OnEnable.
Declaration
public static RigBuilder.OnAddRigBuilderCallback onAddRigBuilder
Field Value
Type | Description |
---|---|
RigBuilder.OnAddRigBuilderCallback |
onRemoveRigBuilder
Notification callback that is sent whenever a RigBuilder calls OnDisable.
Declaration
public static RigBuilder.OnRemoveRigBuilderCallback onRemoveRigBuilder
Field Value
Type | Description |
---|---|
RigBuilder.OnRemoveRigBuilderCallback |
Properties
graph
Retrieves the PlayableGraph created by this RigBuilder.
Declaration
public PlayableGraph graph { get; }
Property Value
Type | Description |
---|---|
PlayableGraph |
layers
Returns a list of RigLayer associated to this RigBuilder.
Declaration
public List<RigLayer> layers { get; set; }
Property Value
Type | Description |
---|---|
List<RigLayer> |
Methods
Build()
Builds the RigBuilder PlayableGraph.
Declaration
public bool Build()
Returns
Type | Description |
---|---|
Boolean | Returns true if the RigBuilder has created a valid PlayableGraph. Returns false otherwise. |
Build(PlayableGraph)
Builds the RigBuilder playable nodes in an external PlayableGraph.
Declaration
public bool Build(PlayableGraph graph)
Parameters
Type | Name | Description |
---|---|---|
PlayableGraph | graph | Destination PlayableGraph. |
Returns
Type | Description |
---|---|
Boolean | Returns true if the RigBuilder has created Playable nodes. Returns false otherwise. |
BuildPreviewGraph(PlayableGraph, Playable)
Appends custom Playable nodes to the animation previewer PlayableGraph.
Declaration
public Playable BuildPreviewGraph(PlayableGraph graph, Playable inputPlayable)
Parameters
Type | Name | Description |
---|---|---|
PlayableGraph | graph | The animation previewer PlayableGraph |
Playable | inputPlayable | The current root of the PlayableGraph |
Returns
Type | Description |
---|---|
Playable |
Implements
Clear()
Destroys the RigBuilder PlayableGraph and frees associated RigLayers memory.
Declaration
public void Clear()
Evaluate(Single)
Updates the RigBuilder layers and evaluates the PlayableGraph manually.
Declaration
public void Evaluate(float deltaTime)
Parameters
Type | Name | Description |
---|---|---|
Single | deltaTime | The time in seconds by which to advance the RigBuilder PlayableGraph. |
Examples
Manually evaluate the RigBuilder in LateUpdate.
[RequireComponent(typeof(RigBuilder))]
public class CustomRigBuilderEvaluator : MonoBehaviour
{
private RigBuilder m_RigBuilder;
void OnEnable()
{
m_RigBuilder = GetComponent<RigBuilder>();
// Disable the RigBuilder and set its PlayableGraph to manual update mode
// to let the script evaluate it instead.
m_RigBuilder.enabled = false;
if (m_RigBuilder.Build())
{
m_RigBuilder.graph.SetTimeUpdateMode(DirectorUpdateMode.Manual);
}
}
void LateUpdate()
{
m_RigBuilder.Evaluate(Time.deltaTime);
}
}
StartPreview()
Notification callback when the animation previewer starts previewing an AnimationClip.
Declaration
public void StartPreview()
Implements
Remarks
This is called by the Animation Window or the Timeline Editor.
StopPreview()
Notification callback when the animation previewer stops previewing an AnimationClip.
Declaration
public void StopPreview()
Implements
Remarks
This is called by the Animation Window or the Timeline Editor.
SyncLayers()
Synchronizes rigs and constraints with scene values. This must be called before evaluating the PlayableGraph.
Declaration
public void SyncLayers()
Examples
Synchronizing layers before evaluating a PlayableGraph created outside the RigBuilder in LateUpdate.
[RequireComponent(typeof(RigBuilder))]
public class CustomPlayableGraphEvaluator : MonoBehaviour
{
private RigBuilder m_RigBuilder;
private PlayableGraph m_PlayableGraph;
void OnEnable()
{
m_RigBuilder = GetComponent<RigBuilder>();
m_PlayableGraph = PlayableGraph.Create();
m_PlayableGraph.SetTimeUpdateMode(DirectorUpdateMode.Manual);
m_RigBuilder.Build(m_PlayableGraph);
}
void OnDisable()
{
if (m_PlayableGraph.IsValid())
m_PlayableGraph.Destroy();
}
void LateUpdate()
{
m_RigBuilder.SyncLayers();
m_PlayableGraph.Evaluate(Time.deltaTime);
}
}
See Also
UpdatePreviewGraph(PlayableGraph)
Notification callback when the animation previewer updates its PlayableGraph before sampling an AnimationClip.
Declaration
public void UpdatePreviewGraph(PlayableGraph graph)
Parameters
Type | Name | Description |
---|---|---|
PlayableGraph | graph | The animation previewer PlayableGraph |
Implements
Remarks
This is called by the Animation Window or the Timeline Editor.