Character Skeleton is used to store bone hierarchy and get bone references at runtime:
Character Skeleton component.
Skeleton is a list of all bone transforms.
Skeleton Bone Chains lists auto-generated bone chains for different parts of the body.
Tip: To update the hierarchy, click the “Update Skeleton” button and apply changes to the prefab.
This component is added to the root bone (e.g., root, armature, skeleton, etc.)m and it’s used by Animation Modifiers and Layered Blending to select bones in the editor.
This simple interface plays a crucial role in editor bone selection:
public interface IRigProvider{ public KRigElement[] GetHierarchy();}
KRigElement is a struct that has 2 fields:
name (string).
index (int).
depth (int).
It implements a custom drawer that tries to get a Rig Provider from the parent. For example, Procedural Animation Settings asset has a reference to the Character Prefab. When a bone is picked, it will try to get the Character Skeleton component and return the array of rig elements.
// Returns a list of all bones in the hierarchy.public List<CharacterSkeletonBone> SkeletonBones => skeleton;// Returns all bone chains in this skeleton.public List<KRigElementChain> ElementChains => skeletonBoneChains;
Methods
// Recursively finds all child transforms of the root bone.public void UpdateSkeleton()// Returns all rig elements in this skeleton.public KRigElement[] GetRigElements()// Returns a rig element by a Transform reference.public KRigElement GetRigElement(Transform bone)// Returns a rig element by name.public KRigElement GetRigElement(string boneName)// Returns a skeleton bone by index.public CharacterSkeletonBone GetSkeletonBoneByIndex(int index)// Returns all boen transforms in ths skeleton.public Transform[] GetTransformHierarchy()// Returns a bone transform by name.public Transform GetBoneTransform(string boneName)// Returns a bone transform by rig element.// It will try to use element index first.public Transform GetBoneTransform(KRigElement element)// Cached all bone transforms.// This shouldn't be used at runtime.public void CacheSkeletonPose()// Applies bone transform cache.// This shouldn't be used at runtime.public void RestoreCachedSkeletonPose()