mask | 将保存遮罩值到的AvatarMask。 |
将剪辑中的当前遮罩设置复制到AvatarMask。
在编写AssetPostprocessor时,请使用此方法从剪辑配置中复制AvatarMask,以便您可以修改它。
注意:您需要使用ModelImporterClipAnimation.ConfigureClipFromMask将AvatarMask重新应用到ModelImporterClipAnimation。
另请参见:ModelImporterClipAnimation.ConfigureClipFromMask。
using UnityEditor; using UnityEngine;
public class CopyAvatarMask : AssetPostprocessor { void OnPreprocessAnimation() { var modelImporter = assetImporter as ModelImporter;
//Create a new AvatarMask to edit the mask var mask = new AvatarMask(); var clips = modelImporter.clipAnimations;
//Acquire the mask from the clip clips[0].ConfigureMaskFromClip(ref mask);
//Filter out the first non-root (0) bone mask.SetTransformActive(1, false);
//Apply the mask back to the clip clips[0].ConfigureClipFromMask(mask);
//Apply the clips back to the ModelImporter modelImporter.clipAnimations = clips;
//Destroy the AvatarMask since we're not using it anymore Object.DestroyImmediate(mask); } }