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)
Declaration
public override Dictionary<BoneMapping, Transform> Map(AssetLoaderContext assetLoaderContext)
Parameters
Type | Name | Description |
---|---|---|
AssetLoaderContext | assetLoaderContext | The context containing the loaded model and relevant settings. |
Returns
Type | Description |
---|---|
Dictionary<BoneMapping, Transform> | A Dictionary<TKey, TValue> mapping each human bone (via TriLibCore.General.BoneMapping) to the corresponding UnityEngine.Transform from the model hierarchy. |
Overrides
Remarks
This method iterates through each TriLibCore.General.BoneMapping in BonesMapping and checks each of its candidate bone names. For each candidate, it clears a local list, then recursively searches the TriLibCore.AssetLoaderContext.RootGameObject's transform hierarchy for matches. If a matching transform is found and it corresponds to an actual bone (indicated by IModel.IsBone), the mapping is added. If a required bone is not found, a warning is logged (if enabled) and an empty mapping is returned.