private void UpdateMask(ClipAnimationMaskType maskType)
        {
            if (this.clipInfo == null)
            {
                return;
            }
            if (maskType == ClipAnimationMaskType.CreateFromThisModel)
            {
                SerializedObject serializedObject = this.clipInfo.maskTypeProperty.serializedObject;
                ModelImporter    modelImporter    = serializedObject.targetObject as ModelImporter;
                AvatarMaskUtility.UpdateTransformMask(this.m_TransformMask, modelImporter.transformPaths, this.humanTransforms);
                this.FillNodeInfos();
            }
            else if (maskType == ClipAnimationMaskType.CopyFromOther)
            {
                AvatarMask avatarMask = this.clipInfo.maskSourceProperty.objectReferenceValue as AvatarMask;
                if (avatarMask != null)
                {
                    AvatarMask avatarMask2 = this.target as AvatarMask;
                    avatarMask2.Copy(avatarMask);
                    if (this.humanTransforms != null)
                    {
                        AvatarMaskUtility.SetActiveHumanTransforms(avatarMask2, this.humanTransforms);
                    }
                    this.clipInfo.MaskToClip(avatarMask2);
                    this.FillNodeInfos();
                }
            }
            AvatarMask mask = this.target as AvatarMask;

            this.clipInfo.MaskFromClip(mask);
        }
Example #2
0
 private void UpdateMask(ClipAnimationMaskType maskType)
 {
     if (this.clipInfo == null)
     {
         return;
     }
     if (maskType == ClipAnimationMaskType.CreateFromThisModel)
     {
         AvatarMaskUtility.UpdateTransformMask(this.m_TransformMask, (this.clipInfo.maskTypeProperty.serializedObject.targetObject as ModelImporter).transformPaths, this.humanTransforms);
         this.FillNodeInfos();
     }
     else if (maskType == ClipAnimationMaskType.CopyFromOther)
     {
         AvatarMask objectReferenceValue = this.clipInfo.maskSourceProperty.objectReferenceValue as AvatarMask;
         if ((UnityEngine.Object)objectReferenceValue != (UnityEngine.Object)null)
         {
             AvatarMask target = this.target as AvatarMask;
             target.Copy(objectReferenceValue);
             if (this.humanTransforms != null)
             {
                 AvatarMaskUtility.SetActiveHumanTransforms(target, this.humanTransforms);
             }
             this.clipInfo.MaskToClip(target);
             this.FillNodeInfos();
         }
     }
     this.clipInfo.MaskFromClip(this.target as AvatarMask);
 }
Example #3
0
        public static string[] GetAvatarHumanAndActiveExtraTransforms(SerializedObject so, SerializedProperty transformMaskProperty, string[] refTransformsPath)
        {
            SerializedProperty serializedProperty = so.FindProperty(AvatarMaskUtility.sHuman);

            string[] result;
            if (serializedProperty == null || !serializedProperty.isArray)
            {
                result = null;
            }
            else
            {
                List <string> list = new List <string>();
                for (int i = 0; i < serializedProperty.arraySize; i++)
                {
                    SerializedProperty serializedProperty2 = serializedProperty.GetArrayElementAtIndex(i).FindPropertyRelative(AvatarMaskUtility.sBoneName);
                    list.Add(serializedProperty2.stringValue);
                }
                List <string> list2 = new List <string>(AvatarMaskUtility.TokeniseHumanTransformsPath(refTransformsPath, list.ToArray()));
                for (int j = 0; j < transformMaskProperty.arraySize; j++)
                {
                    float  floatValue  = transformMaskProperty.GetArrayElementAtIndex(j).FindPropertyRelative("m_Weight").floatValue;
                    string stringValue = transformMaskProperty.GetArrayElementAtIndex(j).FindPropertyRelative("m_Path").stringValue;
                    if (floatValue > 0f && !list2.Contains(stringValue))
                    {
                        list2.Add(stringValue);
                    }
                }
                result = list2.ToArray();
            }
            return(result);
        }
        private void SetTransformMaskFromReference(AnimationClipInfoProperties clipInfo)
        {
            string[] transformPaths  = referenceTransformPaths;
            string[] humanTransforms = animationType == ModelImporterAnimationType.Human ?
                                       AvatarMaskUtility.GetAvatarHumanAndActiveExtraTransforms(serializedObject, clipInfo.transformMaskProperty, transformPaths) :
                                       AvatarMaskUtility.GetAvatarInactiveTransformMaskPaths(clipInfo.transformMaskProperty);

            AvatarMaskUtility.UpdateTransformMask(clipInfo.transformMaskProperty, transformPaths, humanTransforms, animationType == ModelImporterAnimationType.Human);
        }
 private void ImportAvatarReference()
 {
     EditorGUI.BeginChangeCheck();
     this.m_RefAvatar = (EditorGUILayout.ObjectField("Use skeleton from", this.m_RefAvatar, typeof(Avatar), true, new GUILayoutOption[0]) as Avatar);
     if (EditorGUI.EndChangeCheck())
     {
         this.m_RefImporter = (AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(this.m_RefAvatar)) as ModelImporter);
     }
     if (this.m_RefImporter != null && GUILayout.Button("Import skeleton", new GUILayoutOption[0]))
     {
         AvatarMaskUtility.UpdateTransformMask(this.m_TransformMask, this.m_RefImporter.transformPaths, null);
     }
 }
Example #6
0
 private void ImportAvatarReference()
 {
     EditorGUI.BeginChangeCheck();
     this.m_RefAvatar = EditorGUILayout.ObjectField("Use skeleton from", (UnityEngine.Object) this.m_RefAvatar, typeof(Avatar), true, new GUILayoutOption[0]) as Avatar;
     if (EditorGUI.EndChangeCheck())
     {
         this.m_RefImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath((UnityEngine.Object) this.m_RefAvatar)) as ModelImporter;
     }
     if (!((UnityEngine.Object) this.m_RefImporter != (UnityEngine.Object)null) || !GUILayout.Button("Import skeleton"))
     {
         return;
     }
     AvatarMaskUtility.UpdateTransformMask(this.m_TransformMask, this.m_RefImporter.transformPaths, (string[])null);
 }
Example #7
0
        private void ImportAvatarReference()
        {
            EditorGUI.BeginChangeCheck();
            m_RefAvatar = EditorGUILayout.ObjectField("Use skeleton from", m_RefAvatar, typeof(Avatar), true) as Avatar;
            if (EditorGUI.EndChangeCheck())
            {
                m_RefImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(m_RefAvatar)) as ModelImporter;
            }

            if (m_RefImporter != null && GUILayout.Button("Import skeleton"))
            {
                AvatarMaskUtility.UpdateTransformMask(m_TransformMask, m_RefImporter.transformPaths, null);
            }
        }
        public static string[] GetAvatarHumanTransform(SerializedObject so, string[] refTransformsPath)
        {
            SerializedProperty serializedProperty = so.FindProperty(AvatarMaskUtility.sHuman);

            if (serializedProperty == null || !serializedProperty.isArray)
            {
                return(null);
            }
            string[] humanTransforms = new string[0];
            for (int i = 0; i < serializedProperty.arraySize; i++)
            {
                SerializedProperty serializedProperty2 = serializedProperty.GetArrayElementAtIndex(i).FindPropertyRelative(AvatarMaskUtility.sBoneName);
                ArrayUtility.Add <string>(ref humanTransforms, serializedProperty2.stringValue);
            }
            return(AvatarMaskUtility.TokeniseHumanTransformsPath(refTransformsPath, humanTransforms));
        }
Example #9
0
        public static string[] GetAvatarHumanTransform(SerializedObject so, string[] refTransformsPath)
        {
            SerializedProperty property = so.FindProperty(AvatarMaskUtility.sHuman);

            if (property == null || !property.isArray)
            {
                return((string[])null);
            }
            string[] array = new string[0];
            for (int index = 0; index < property.arraySize; ++index)
            {
                SerializedProperty propertyRelative = property.GetArrayElementAtIndex(index).FindPropertyRelative(AvatarMaskUtility.sBoneName);
                ArrayUtility.Add <string>(ref array, propertyRelative.stringValue);
            }
            return(AvatarMaskUtility.TokeniseHumanTransformsPath(refTransformsPath, array));
        }
        private void ImportAvatarReference()
        {
            EditorGUI.BeginChangeCheck();
            m_RefAvatar = EditorGUILayout.ObjectField(Styles.SelectAvatarReference, m_RefAvatar, typeof(Avatar), true) as Avatar;
            if (EditorGUI.EndChangeCheck())
            {
                m_RefImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(m_RefAvatar)) as ModelImporter;
            }

            using (new EditorGUI.DisabledScope(m_RefImporter == null))
            {
                if (GUILayout.Button(Styles.ImportAvatarReference))
                {
                    AvatarMaskUtility.UpdateTransformMask(m_TransformMask, m_RefImporter.transformPaths, null);
                }
            }
        }
        private void UpdateMask(ClipAnimationMaskType maskType)
        {
            if (clipInfo == null)
            {
                return;
            }

            if (maskType == ClipAnimationMaskType.CreateFromThisModel)
            {
                SerializedObject so            = clipInfo.maskTypeProperty.serializedObject;
                ModelImporter    modelImporter = so.targetObject as ModelImporter;

                AvatarMaskUtility.UpdateTransformMask(m_TransformMask, modelImporter.transformPaths, humanTransforms);
                UpdateTransformInfos();
            }
            else if (maskType == ClipAnimationMaskType.CopyFromOther)
            {
                AvatarMask maskSource = clipInfo.maskSourceProperty.objectReferenceValue as AvatarMask;
                if (maskSource != null)
                {
                    AvatarMask maskDest = target as AvatarMask;
                    maskDest.Copy(maskSource);

                    // If this is a human clip make sure that all human transform path are set to true
                    if (humanTransforms != null)
                    {
                        AvatarMaskUtility.SetActiveHumanTransforms(maskDest, humanTransforms);
                    }

                    clipInfo.MaskToClip(maskDest);
                    UpdateTransformInfos();
                }
            }
            else if (maskType == ClipAnimationMaskType.None)
            {
                var emptyMask = new AvatarMask();
                ModelImporter.UpdateTransformMask(emptyMask, clipInfo.transformMaskProperty);
            }

            AvatarMask mask = target as AvatarMask;

            clipInfo.MaskFromClip(mask);
        }
        private void AddClip(TakeInfo takeInfo)
        {
            this.m_ClipAnimations.InsertArrayElementAtIndex(this.m_ClipAnimations.arraySize);
            AnimationClipInfoProperties animationClipInfoAtIndex = this.GetAnimationClipInfoAtIndex(this.m_ClipAnimations.arraySize - 1);

            animationClipInfoAtIndex.name = this.MakeUniqueClipName(takeInfo.defaultClipName, -1);
            this.SetupTakeNameAndFrames(animationClipInfoAtIndex, takeInfo);
            animationClipInfoAtIndex.wrapMode                = 0;
            animationClipInfoAtIndex.loop                    = false;
            animationClipInfoAtIndex.orientationOffsetY      = 0f;
            animationClipInfoAtIndex.level                   = 0f;
            animationClipInfoAtIndex.cycleOffset             = 0f;
            animationClipInfoAtIndex.loopTime                = false;
            animationClipInfoAtIndex.loopBlend               = false;
            animationClipInfoAtIndex.loopBlendOrientation    = false;
            animationClipInfoAtIndex.loopBlendPositionY      = false;
            animationClipInfoAtIndex.loopBlendPositionXZ     = false;
            animationClipInfoAtIndex.keepOriginalOrientation = false;
            animationClipInfoAtIndex.keepOriginalPositionY   = true;
            animationClipInfoAtIndex.keepOriginalPositionXZ  = false;
            animationClipInfoAtIndex.heightFromFeet          = false;
            animationClipInfoAtIndex.mirror                  = false;
            animationClipInfoAtIndex.maskType                = ClipAnimationMaskType.CreateFromThisModel;
            AvatarMask mask = new AvatarMask();

            string[]         humanTransforms  = null;
            SerializedObject serializedObject = animationClipInfoAtIndex.maskTypeProperty.serializedObject;
            ModelImporter    targetObject     = serializedObject.targetObject as ModelImporter;

            if ((this.animationType == ModelImporterAnimationType.Human) && !targetObject.isAssetOlderOr42)
            {
                humanTransforms = AvatarMaskUtility.GetAvatarHumanTransform(serializedObject, targetObject.transformPaths);
                if (humanTransforms == null)
                {
                    return;
                }
            }
            AvatarMaskUtility.UpdateTransformMask(mask, targetObject.transformPaths, humanTransforms);
            animationClipInfoAtIndex.MaskToClip(mask);
            animationClipInfoAtIndex.ClearEvents();
            animationClipInfoAtIndex.ClearCurves();
            UnityEngine.Object.DestroyImmediate(mask);
        }
Example #13
0
        public static string[] GetAvatarHumanTransform(SerializedObject so, string[] refTransformsPath)
        {
            SerializedProperty serializedProperty = so.FindProperty(AvatarMaskUtility.sHuman);

            string[] result;
            if (serializedProperty == null || !serializedProperty.isArray)
            {
                result = null;
            }
            else
            {
                List <string> list = new List <string>();
                for (int i = 0; i < serializedProperty.arraySize; i++)
                {
                    SerializedProperty serializedProperty2 = serializedProperty.GetArrayElementAtIndex(i).FindPropertyRelative(AvatarMaskUtility.sBoneName);
                    list.Add(serializedProperty2.stringValue);
                }
                result = AvatarMaskUtility.TokeniseHumanTransformsPath(refTransformsPath, list.ToArray());
            }
            return(result);
        }
 private void SetTransformMaskFromReference(AnimationClipInfoProperties clipInfo)
 {
     string[] referenceTransformPaths = this.referenceTransformPaths;
     string[] humanTransforms         = (this.animationType != ModelImporterAnimationType.Human) ? null : AvatarMaskUtility.GetAvatarHumanTransform(base.serializedObject, referenceTransformPaths);
     AvatarMaskUtility.UpdateTransformMask(clipInfo.transformMaskProperty, referenceTransformPaths, humanTransforms);
 }