Documentation

Unity Engine

Download Unity

Unity Engine

RigBuilder

An intermediate data representing the rig.
Read time 3 minutesLast updated 3 hours ago

Definition

[BurstCompile]public struct RigBuilder : IDisposable

Remarks

If you don't use the Skeleton but your own custom rig representation, as long as you have a method to convert this representation to a RigBuilder, we can build a RigDefinition from it.
The following example uses the
Unity.Animations
,
Unity.Collections
,
Unity.Entities
,
Unity.Mathematics
, and
UnityEngine
namespaces. It builds a rig definition with three bones and one float channel.
Additional Resources: RigDefinition, BindingSet

Examples

// This example builds a rig definition for a three-bone character with one float channel.// The caller owns the returned rig definition and must dispose it.public static BlobObjectReference<RigDefinition> BuildCharacterRig(){ using RigBuilder rigBuilder = new RigBuilder(Allocator.Temp); // Add the bones. Add the parent of a bone before the bone itself. // The root bone has a ParentIndex of -1. rigBuilder.Add(new SkeletonNode { Id = "Root", ParentIndex = -1, LocalTranslationDefaultValue = float3.zero, LocalRotationDefaultValue = quaternion.identity, LocalScaleDefaultValue = new float3(1f) }); rigBuilder.Add(new SkeletonNode { Id = "Spine", ParentIndex = 0, LocalTranslationDefaultValue = new float3(0f, 1f, 0f), LocalRotationDefaultValue = quaternion.identity, LocalScaleDefaultValue = new float3(1f) }); rigBuilder.Add(new SkeletonNode { Id = "Head", ParentIndex = 1, LocalTranslationDefaultValue = new float3(0f, 0.5f, 0f), LocalRotationDefaultValue = quaternion.identity, LocalScaleDefaultValue = new float3(1f) }); // Add a float channel that animation can write to. The channel is the intensity of a light on the Head bone. // Clips find the channel through the identifier that FloatChannel.Create computes from the transform path // and the property name. The property name is the serialized name m_Intensity, not intensity. The last // argument is the default value of the channel. rigBuilder.Add(FloatChannel.Create("Root/Spine/Head", typeof(Light), "m_Intensity", 1f)); // Create the immutable rig definition. The result has three bones and one float channel. return rigBuilder.ToRigDefinition();}

Constructors

Constructor

Description

RigBuilder(Unity.Collections.Allocator)RigBuilder constructor.

Properties

Property

Description

IsCreatedReturns true if the RigBuilder has been properly created.
RootMotionBoneIdThe identifier of the bone whose motion gives the root motion of a clip.

Methods

Method

Description

AddAdds an EntityIdChannel to the RigBuilder.
ClearClears all RigBuilder channels.
DisposeDisposes the RigBuilder.
GetBoneIndexFinds the index of the skeleton node that has an identifier.
RemoveRemoves the entity ID channels that have the same identifier as a channel.
ReplaceReplaces the entity ID channel that has the same identifier as a channel.
ToRigDefinitionCreates a RigDefinition from the current RigBuilder data.
TryGetGets the skeleton node at a bone index.
TrySetBoneDefaultRotationSets the default rotation of the bone at a bone index.
TrySetBoneDefaultScaleSets the default scale of the bone at a bone index.
TrySetBoneDefaultTranslationSets the default translation of the bone at a bone index.
TrySetDefaultEntityIdSets the default value of the entity ID channel that has an identifier.
TrySetDefaultFloatSets the default value of the float channel that has an identifier.
TrySetDefaultIntSets the default value of the integer channel that has an identifier.
TrySetDefaultRotationSets the default value of the rotation channel that has an identifier.
TrySetDefaultScaleSets the default value of the scale channel that has an identifier.
TrySetDefaultTranslationSets the default value of the translation channel that has an identifier.

Static Methods

Method

Description

CreateCreate RigBuilder from an Avatar asset.