Class ByNameHumanoidAvatarMapper
Implements a humanoid avatar mapping strategy by matching the names of loaded GameObjects with candidate bone names specified in a bone mapping list. For each human bone defined in the mapping, the first matching GameObject found in the model hierarchy is used. If a required bone is not found, a warning is issued.
Inherited Members
Namespace: TriLibCore.Mappers
Assembly: Assembly-CSharp.dll
Syntax
[CreateAssetMenu(menuName = "TriLib/Mappers/Humanoid/By Name Humanoid Avatar Mapper", fileName = "ByNameHumanoidAvatarMapper")]
public class ByNameHumanoidAvatarMapper : HumanoidAvatarMapper
Fields
BonesMapping
A list of bone mappings that define how human bones (e.g. Hips
, Spine
) map to possible
GameObject names in the imported model.
Declaration
public List<BoneMapping> BonesMapping
Field Value
Type | Description |
---|---|
List<BoneMapping> |
CaseInsensitive
Indicates whether string comparisons are performed in a case-insensitive manner.
Declaration
public bool CaseInsensitive
Field Value
Type | Description |
---|---|
bool |
stringComparisonMode
Specifies the string comparison mode to use when matching loaded GameObject names against candidate names defined in the bone mapping.
Declaration
[Header("Left = Loaded GameObjects Names, Right = Names in BonesMapping.BoneNames")]
public StringComparisonMode stringComparisonMode
Field Value
Type | Description |
---|---|
StringComparisonMode |
Remarks
The "left" value is the name of the loaded GameObject and the "right" value is one of the candidate names.
Methods
AddMapping(HumanBodyBones, HumanLimit, params string[])
Adds a new bone mapping to the current list of mappings. This method allows dynamically adding an entry that associates a specific human bone with one or more candidate transform names and an optional human limit.
Declaration
public void AddMapping(HumanBodyBones humanBodyBones, HumanLimit humanLimit, params string[] boneNames)
Parameters
Type | Name | Description |
---|---|---|
HumanBodyBones | humanBodyBones | The human bone (as defined in UnityEngine.HumanBodyBones) to map. |
HumanLimit | humanLimit | The constraints or limits associated with this bone. |
string[] | boneNames | The candidate transform names to search for in the model hierarchy. |
Map(AssetLoaderContext)
Attempts to map the loaded model bones into a humanoid rig, returning a Dictionary<TKey, TValue> for further processing. This method can be overridden to implement custom bone search or heuristics.
Declaration
public override Dictionary<BoneMapping, Transform> Map(AssetLoaderContext assetLoaderContext)
Parameters
Type | Name | Description |
---|---|---|
AssetLoaderContext | assetLoaderContext | The AssetLoaderContext containing references to the loaded GameObject hierarchy and relevant import options. |
Returns
Type | Description |
---|---|
Dictionary<BoneMapping, Transform> | A dictionary mapping each humanoid BoneMapping entry to the
corresponding UnityEngine.Transform in the scene. By default, returns |