示例#1
0
    private static void Init()
    {
        UnityEngine.Object[] selection = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets);
        foreach (UnityEngine.Object obj in selection)
        {
            string        path = AssetDatabase.GetAssetPath(obj);
            ModelImporter mi   = AssetImporter.GetAtPath(path) as ModelImporter;

            Type modelImporterType = typeof(ModelImporter);

            MethodInfo updateTransformMaskMethodInfo = modelImporterType.GetMethod("UpdateTransformMask", BindingFlags.NonPublic | BindingFlags.Static);

            ModelImporterClipAnimation[] clipAnimations = mi.clipAnimations;
            SerializedObject             so             = new SerializedObject(mi);
            SerializedProperty           clips          = so.FindProperty("m_ClipAnimations");

            UnityEngine.AvatarMask avatarMask = new UnityEngine.AvatarMask();
            avatarMask.transformCount = mi.transformPaths.Length;
            for (int i = 0; i < mi.transformPaths.Length; i++)
            {
                avatarMask.SetTransformPath(i, mi.transformPaths[i]);
                avatarMask.SetTransformActive(i, true);
            }

            for (int i = 0; i < clipAnimations.Length; i++)
            {
                SerializedProperty transformMaskProperty = clips.GetArrayElementAtIndex(i).FindPropertyRelative("transformMask");
                updateTransformMaskMethodInfo.Invoke(mi, new System.Object[] { avatarMask, transformMaskProperty });
            }

            so.ApplyModifiedProperties();

            AssetDatabase.ImportAsset(path);
        }
    }
 static public int SetTransformActive(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.AvatarMask self = (UnityEngine.AvatarMask)checkSelf(l);
         System.Int32           a1;
         checkType(l, 2, out a1);
         System.Boolean a2;
         checkType(l, 3, out a2);
         self.SetTransformActive(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
 static public int SetTransformActive(IntPtr l)
 {
     try {
         UnityEngine.AvatarMask self = (UnityEngine.AvatarMask)checkSelf(l);
         System.Int32           a1;
         checkType(l, 2, out a1);
         System.Boolean a2;
         checkType(l, 3, out a2);
         self.SetTransformActive(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }