This picture is taken from the mask section of animation import settings, for a specific animation. As can be seen, one box is unchecked. I need his box checked for things to work properly.
Right now i’m in a phase of repeatedly reimporting animations, setting this value manually every time will get tiresome very quickly.
Is there any way i can just make all of these boxes checked by default?
using UnityEngine;
using UnityEditor;
using System.Collections;
public class importModel : AssetPostprocessor {
void OnPostprocessModel ( GameObject g ) {
ModelImporter m = (ModelImporter) assetImporter;
if ( m.clipAnimations[0].maskType == ClipAnimationMaskType.CreateFromThisModel ) {
//??
}
}
}
Certainly, the mode more useful sounding OnPreprocessAnimation is definitely Unity 5, and the AvatarkMask class was moved to the animtions namespace (still internal for me)
Yeah. If you need to check, just put a debug.log(path) inside the loop to see what they all are
Or if there’s only one weapon, maybe just if(path.Contains(“weapon”))
Thanks, here is a cleaned up version that applies the mask to all of the model’s animation clips:
var bonesToEnable = new List<string>
{
"Root/GenericBone1",
"Root/GenericBone2",
};
// Enable the bones for ALL of the model's animation clips.
for (var i = 0; i < modelImporter.clipAnimations.Length; i++)
{
var clip = modelImporter.clipAnimations[i];
if (clip.maskType != ClipAnimationMaskType.CreateFromThisModel) continue;
var serializedObject = new SerializedObject(modelImporter);
var transformMask = serializedObject.FindProperty($"m_ClipAnimations.Array.data[{i}].transformMask");
var arrayProperty = transformMask.FindPropertyRelative("Array");
for (var j = 0; j < arrayProperty.arraySize; j++)
{
var element = arrayProperty.GetArrayElementAtIndex(j);
if (bonesToEnable.Contains(element.FindPropertyRelative("m_Path").stringValue))
{
element.FindPropertyRelative("m_Weight").floatValue = 1;
}
}
serializedObject.ApplyModifiedProperties();
}