public EventModificationContextMenuObject(AnimationClipInfoProperties info, float time, int index, bool[] selected)
 {
     this.m_Info     = info;
     this.m_Time     = time;
     this.m_Index    = index;
     this.m_Selected = selected;
 }
 public void UpdateEvent(AnimationClipInfoProperties info)
 {
     if (this.m_Event != null)
     {
         this.m_Event.clipInfo = info;
     }
 }
Ejemplo n.º 3
0
        string FindNextAvailableName(string baseName)
        {
            string[] allClipNames = new string[m_ClipAnimations.arraySize];
            for (int i = 0; i < m_ClipAnimations.arraySize; ++i)
            {
                AnimationClipInfoProperties clip = GetAnimationClipInfoAtIndex(i);
                allClipNames[i] = clip.name;
            }
            Array.Sort(allClipNames, StringComparer.InvariantCulture);
            string resultName = baseName;

            for (var i = 0; i < allClipNames.Length; i++)
            {
                var found = Array.BinarySearch(allClipNames, resultName);
                if (found < 0)
                {
                    return(resultName);
                }

                var nextNumber = i + 1;
                resultName = baseName + " (" + nextNumber + ")";
            }

            return(resultName);
        }
Ejemplo n.º 4
0
 private void SelectClip(int selected)
 {
     if (EditorGUI.s_DelayedTextEditor != null && Event.current != null)
     {
         EditorGUI.s_DelayedTextEditor.EndGUI(Event.current.type);
     }
     this.DestroyEditorsAndData();
     this.selectedClipIndex = selected;
     if (this.selectedClipIndex < 0 || this.selectedClipIndex >= this.m_ClipAnimations.arraySize)
     {
         this.selectedClipIndex = -1;
     }
     else
     {
         AnimationClipInfoProperties animationClipInfoAtIndex = this.GetAnimationClipInfoAtIndex(selected);
         AnimationClip animationClipForTake = this.singleImporter.GetPreviewAnimationClipForTake(animationClipInfoAtIndex.takeName);
         if (!((UnityEngine.Object)animationClipForTake != (UnityEngine.Object)null))
         {
             return;
         }
         this.m_AnimationClipEditor = (AnimationClipEditor)Editor.CreateEditor((UnityEngine.Object)animationClipForTake);
         this.InitMask(animationClipInfoAtIndex);
         this.SyncClipEditor();
     }
 }
        void AddClipInList(ReorderableList list)
        {
            if (m_DefaultClipsSerializedObject != null)
            {
                TransferDefaultClipsToCustomClips();
            }


            int takeIndex = 0;

            if (0 < selectedClipIndex && selectedClipIndex < m_ClipAnimations.arraySize)
            {
                AnimationClipInfoProperties info = GetAnimationClipInfoAtIndex(selectedClipIndex);
                for (int i = 0; i < singleImporter.importedTakeInfos.Length; i++)
                {
                    if (singleImporter.importedTakeInfos[i].name == info.takeName)
                    {
                        takeIndex = i;
                        break;
                    }
                }
            }

            AddClip(singleImporter.importedTakeInfos[takeIndex]);
            UpdateList();
            SelectClip(list.list.Count - 1);
        }
        void SelectClip(int selected)
        {
            // If you were editing Clip Name (delayed text field had focus) and then selected a new clip from the clip list,
            // the active string in the delayed text field would get applied to the new selected clip instead of the old.
            // HACK: Calling EndGUI here on the recycled delayed text editor seems to fix this issue.
            // Sometime we should reimplement delayed text field code to not be super confusing and then fix the issue more properly.
            if (EditorGUI.s_DelayedTextEditor != null && Event.current != null)
            {
                EditorGUI.s_DelayedTextEditor.EndGUI(Event.current.type);
            }

            DestroyEditorsAndData();

            selectedClipIndex = selected;
            if (selectedClipIndex < 0 || selectedClipIndex >= m_ClipAnimations.arraySize)
            {
                selectedClipIndex = -1;
                return;
            }

            AnimationClipInfoProperties info = GetAnimationClipInfoAtIndex(selected);
            AnimationClip clip = singleImporter.GetPreviewAnimationClipForTake(info.takeName);

            if (clip != null)
            {
                m_AnimationClipEditor = (AnimationClipEditor)Editor.CreateEditor(clip, typeof(AnimationClipEditor));
                InitMask(info);
                SyncClipEditor();
            }
        }
        void AddClip(TakeInfo takeInfo)
        {
            string uniqueName = MakeUniqueClipName(takeInfo.defaultClipName);

            m_ClipAnimations.InsertArrayElementAtIndex(m_ClipAnimations.arraySize);
            AnimationClipInfoProperties info = GetAnimationClipInfoAtIndex(m_ClipAnimations.arraySize - 1);

            info.name = uniqueName;
            SetupTakeNameAndFrames(info, takeInfo);
            info.wrapMode                = (int)WrapMode.Default;
            info.loop                    = false;
            info.orientationOffsetY      = 0;
            info.level                   = 0;
            info.cycleOffset             = 0;
            info.loopTime                = false;
            info.loopBlend               = false;
            info.loopBlendOrientation    = false;
            info.loopBlendPositionY      = false;
            info.loopBlendPositionXZ     = false;
            info.keepOriginalOrientation = false;
            info.keepOriginalPositionY   = true;
            info.keepOriginalPositionXZ  = false;
            info.heightFromFeet          = false;
            info.mirror                  = false;
            info.maskType                = ClipAnimationMaskType.None;

            SetBodyMaskDefaultValues(info);


            info.ClearEvents();
            info.ClearCurves();
        }
        /// <summary>
        /// Finds the next duplicate number.
        /// </summary>
        /// <returns>The next duplicate number (-1 if there is no other clip with the same name).</returns>
        /// <param name="baseName">Base name.</param>
        int FindNextDuplicateNumber(string baseName)
        {
            int nextNumber = -1;

            for (int i = 0; i < m_ClipAnimations.arraySize; ++i)
            {
                AnimationClipInfoProperties clip = GetAnimationClipInfoAtIndex(i);

                int    clipNumber;
                string clipBaseName = RemoveDuplicateSuffix(clip.name, out clipNumber);
                if (clipBaseName == baseName)
                {
                    // Same base, so next number is at least 1.
                    if (nextNumber == -1)
                    {
                        nextNumber = 1;
                    }

                    // Next number is one more than the maximum number found.
                    if (clipNumber != -1)
                    {
                        nextNumber = Math.Max(nextNumber, clipNumber + 1);
                    }
                }
            }

            return(nextNumber);
        }
        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.None;
            this.SetBodyMaskDefaultValues(animationClipInfoAtIndex);
            this.SetTransformMaskFromReference(animationClipInfoAtIndex);
            animationClipInfoAtIndex.ClearEvents();
            animationClipInfoAtIndex.ClearCurves();
        }
        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 SyncClipEditor()
 {
     if (!(this.m_AnimationClipEditor == null) && !(this.m_MaskInspector == null))
     {
         AnimationClipInfoProperties animationClipInfoAtIndex = this.GetAnimationClipInfoAtIndex(this.selectedClipIndex);
         this.m_MaskInspector.clipInfo = animationClipInfoAtIndex;
         this.m_AnimationClipEditor.ShowRange(animationClipInfoAtIndex);
         this.m_AnimationClipEditor.mask = this.m_Mask;
     }
 }
        private void SetBodyMaskDefaultValues(AnimationClipInfoProperties clipInfo)
        {
            SerializedProperty bodyMask = clipInfo.bodyMaskProperty;

            bodyMask.ClearArray();
            for (int i = 0; i < (int)AvatarMaskBodyPart.LastBodyPart; ++i)
            {
                bodyMask.InsertArrayElementAtIndex(i);
                bodyMask.GetArrayElementAtIndex(i).intValue = 1;
            }
        }
 public static AnimationWindowEvent Edit(AnimationClipInfoProperties clipInfo, int eventIndex)
 {
     AnimationWindowEvent event2 = ScriptableObject.CreateInstance<AnimationWindowEvent>();
     event2.hideFlags = HideFlags.HideInHierarchy;
     event2.name = "Animation Event";
     event2.root = null;
     event2.clip = null;
     event2.clipInfo = clipInfo;
     event2.eventIndex = eventIndex;
     return event2;
 }
        private void SetBodyMaskDefaultValues(AnimationClipInfoProperties clipInfo)
        {
            SerializedProperty bodyMaskProperty = clipInfo.bodyMaskProperty;

            bodyMaskProperty.ClearArray();
            for (int i = 0; i < 13; i++)
            {
                bodyMaskProperty.InsertArrayElementAtIndex(i);
                bodyMaskProperty.GetArrayElementAtIndex(i).intValue = 1;
            }
        }
Ejemplo n.º 15
0
        public static AnimationWindowEvent Edit(AnimationClipInfoProperties clipInfo, int eventIndex)
        {
            AnimationWindowEvent animationWindowEvent = ScriptableObject.CreateInstance <AnimationWindowEvent>();

            animationWindowEvent.hideFlags  = HideFlags.HideInHierarchy;
            animationWindowEvent.name       = "Animation Event";
            animationWindowEvent.root       = null;
            animationWindowEvent.clip       = null;
            animationWindowEvent.clipInfo   = clipInfo;
            animationWindowEvent.eventIndex = eventIndex;
            return(animationWindowEvent);
        }
Ejemplo n.º 16
0
        private void SyncClipEditor()
        {
            if ((UnityEngine.Object) this.m_AnimationClipEditor == (UnityEngine.Object)null || (UnityEngine.Object) this.m_MaskInspector == (UnityEngine.Object)null)
            {
                return;
            }
            AnimationClipInfoProperties animationClipInfoAtIndex = this.GetAnimationClipInfoAtIndex(this.selectedClipIndex);

            this.m_MaskInspector.clipInfo = animationClipInfoAtIndex;
            this.m_AnimationClipEditor.ShowRange(animationClipInfoAtIndex);
            this.m_AnimationClipEditor.mask = this.m_Mask;
        }
 public void UpdateEvents(AnimationClipInfoProperties clipInfo)
 {
     if (this.m_Events != null)
     {
         AnimationWindowEvent[] events = this.m_Events;
         for (int i = 0; i < events.Length; i++)
         {
             AnimationWindowEvent animationWindowEvent = events[i];
             animationWindowEvent.clipInfo = clipInfo;
         }
     }
 }
 private void InitMask(AnimationClipInfoProperties clipInfo)
 {
     if (this.m_Mask == null)
     {
         AnimationClip animationClip = this.m_AnimationClipEditor.target as AnimationClip;
         this.m_Mask                    = new AvatarMask();
         this.m_MaskInspector           = (AvatarMaskInspector)Editor.CreateEditor(this.m_Mask);
         this.m_MaskInspector.canImport = false;
         this.m_MaskInspector.showBody  = animationClip.isHumanMotion;
         this.m_MaskInspector.clipInfo  = clipInfo;
     }
 }
        private void DrawClipElement(Rect rect, int index, bool selected, bool focused)
        {
            AnimationClipInfoProperties info = m_ClipList.list[index] as AnimationClipInfoProperties;

            rect.xMax -= kFrameColumnWidth * 2;
            GUI.Label(rect, info.name, EditorStyles.label);
            rect.x     = rect.xMax;
            rect.width = kFrameColumnWidth;
            GUI.Label(rect, info.firstFrame.ToString("0.0"), styles.numberStyle);
            rect.x = rect.xMax;
            GUI.Label(rect, info.lastFrame.ToString("0.0"), styles.numberStyle);
        }
        private void InitMask(AnimationClipInfoProperties clipInfo)
        {
            if (m_Mask == null)
            {
                AnimationClip clip = m_AnimationClipEditor.target as AnimationClip;

                m_Mask                    = new AvatarMask();
                m_MaskInspector           = (AvatarMaskInspector)Editor.CreateEditor(m_Mask, typeof(AvatarMaskInspector));
                m_MaskInspector.canImport = false;
                m_MaskInspector.showBody  = clip.isHumanMotion;
                m_MaskInspector.clipInfo  = clipInfo;
            }
        }
        public void EditEvents(AnimationClipInfoProperties clipInfo, bool[] selectedIndices)
        {
            List <AnimationWindowEvent> list = new List <AnimationWindowEvent>();

            for (int i = 0; i < selectedIndices.Length; i++)
            {
                if (selectedIndices[i])
                {
                    list.Add(AnimationWindowEvent.Edit(clipInfo, i));
                }
            }
            this.m_Events = list.ToArray();
        }
        void SyncClipEditor(AnimationClipInfoProperties info)
        {
            if (m_AnimationClipEditor == null || m_MaskInspector == null)
            {
                return;
            }

            // It mandatory to set clip info into mask inspector first, this will update m_Mask.
            m_MaskInspector.clipInfo = info;

            m_AnimationClipEditor.ShowRange(info);
            m_AnimationClipEditor.mask = m_Mask;
            AnimationCurvePreviewCache.ClearCache();
        }
Ejemplo n.º 23
0
        private void InitMask(AnimationClipInfoProperties clipInfo)
        {
            if (!((UnityEngine.Object) this.m_Mask == (UnityEngine.Object)null))
            {
                return;
            }
            AnimationClip target = this.m_AnimationClipEditor.target as AnimationClip;

            this.m_Mask                    = new AvatarMask();
            this.m_MaskInspector           = (AvatarMaskInspector)Editor.CreateEditor((UnityEngine.Object) this.m_Mask);
            this.m_MaskInspector.canImport = false;
            this.m_MaskInspector.showBody  = target.isHumanMotion;
            this.m_MaskInspector.clipInfo  = clipInfo;
        }
        void SyncClipEditor()
        {
            if (m_AnimationClipEditor == null || m_MaskInspector == null)
            {
                return;
            }

            AnimationClipInfoProperties info = GetAnimationClipInfoAtIndex(selectedClipIndex);

            // It mandatory to set clip info into mask inspector first, this will update m_Mask.
            m_MaskInspector.clipInfo = info;

            m_AnimationClipEditor.ShowRange(info);
            m_AnimationClipEditor.mask = m_Mask;
        }
 internal static void Edit(AnimationClipInfoProperties clipInfo, int index)
 {
   UnityEngine.Object[] objectsOfTypeAll = Resources.FindObjectsOfTypeAll(typeof (AnimationEventPopup));
   AnimationEventPopup popup = objectsOfTypeAll.Length <= 0 ? (AnimationEventPopup) null : (AnimationEventPopup) objectsOfTypeAll[0];
   if ((UnityEngine.Object) popup == (UnityEngine.Object) null)
   {
     popup = EditorWindow.GetWindow<AnimationEventPopup>(true);
     AnimationEventPopup.InitWindow(popup);
   }
   popup.m_Root = (GameObject) null;
   popup.m_Clip = (AnimationClip) null;
   popup.m_ClipInfo = clipInfo;
   popup.eventIndex = index;
   popup.Repaint();
 }
		internal static void Edit(AnimationClipInfoProperties clipInfo, int index)
		{
			UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(typeof(AnimationEventPopup));
			AnimationEventPopup animationEventPopup = (array.Length <= 0) ? null : ((AnimationEventPopup)array[0]);
			if (animationEventPopup == null)
			{
				animationEventPopup = EditorWindow.GetWindow<AnimationEventPopup>(true);
				AnimationEventPopup.InitWindow(animationEventPopup);
			}
			animationEventPopup.m_Root = null;
			animationEventPopup.m_Clip = null;
			animationEventPopup.m_ClipInfo = clipInfo;
			animationEventPopup.eventIndex = index;
			animationEventPopup.Repaint();
		}
Ejemplo n.º 27
0
        internal static void Edit(AnimationClipInfoProperties clipInfo, int index)
        {
            UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(typeof(AnimationEventPopup));
            AnimationEventPopup  animationEventPopup = (array.Length <= 0) ? null : ((AnimationEventPopup)array[0]);

            if (animationEventPopup == null)
            {
                animationEventPopup = EditorWindow.GetWindow <AnimationEventPopup>(true);
                AnimationEventPopup.InitWindow(animationEventPopup);
            }
            animationEventPopup.m_Root     = null;
            animationEventPopup.m_Clip     = null;
            animationEventPopup.m_ClipInfo = clipInfo;
            animationEventPopup.eventIndex = index;
            animationEventPopup.Repaint();
        }
Ejemplo n.º 28
0
        internal static void Edit(AnimationClipInfoProperties clipInfo, int index)
        {
            UnityEngine.Object[] objectsOfTypeAll = Resources.FindObjectsOfTypeAll(typeof(AnimationEventPopup));
            AnimationEventPopup  popup            = objectsOfTypeAll.Length <= 0 ? (AnimationEventPopup)null : (AnimationEventPopup)objectsOfTypeAll[0];

            if ((UnityEngine.Object)popup == (UnityEngine.Object)null)
            {
                popup = EditorWindow.GetWindow <AnimationEventPopup>(true);
                AnimationEventPopup.InitWindow(popup);
            }
            popup.m_Root     = (GameObject)null;
            popup.m_Clip     = (AnimationClip)null;
            popup.m_ClipInfo = clipInfo;
            popup.eventIndex = index;
            popup.Repaint();
        }
Ejemplo n.º 29
0
        internal static void Edit(AnimationClipInfoProperties clipInfo, int index)
        {
            UnityEngine.Object[] objArray = Resources.FindObjectsOfTypeAll(typeof(AnimationEventPopup));
            AnimationEventPopup  window   = (objArray.Length <= 0) ? null : ((AnimationEventPopup)objArray[0]);

            if (window == null)
            {
                window = EditorWindow.GetWindow <AnimationEventPopup>(true);
                InitWindow(window);
            }
            window.m_Root     = null;
            window.m_Clip     = null;
            window.m_ClipInfo = clipInfo;
            window.eventIndex = index;
            window.Repaint();
        }
Ejemplo n.º 30
0
        private void AvatarMaskSettings(AnimationClipInfoProperties clipInfo)
        {
            if (clipInfo == null || !((UnityEngine.Object) this.m_AnimationClipEditor != (UnityEngine.Object)null))
            {
                return;
            }
            this.InitMask(clipInfo);
            int  indentLevel = EditorGUI.indentLevel;
            bool changed     = GUI.changed;

            ModelImporterClipEditor.m_MaskFoldout = EditorGUILayout.Foldout(ModelImporterClipEditor.m_MaskFoldout, ModelImporterClipEditor.styles.Mask);
            GUI.changed = changed;
            if (clipInfo.maskType == ClipAnimationMaskType.CreateFromThisModel && !this.m_MaskInspector.IsMaskUpToDate())
            {
                GUILayout.BeginHorizontal(EditorStyles.helpBox, new GUILayoutOption[0]);
                GUILayout.Label("Mask does not match hierarchy. Animation might not import correctly", EditorStyles.wordWrappedMiniLabel, new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                GUILayout.BeginVertical();
                GUILayout.Space(5f);
                if (GUILayout.Button("Fix Mask"))
                {
                    this.SetTransformMaskFromReference(clipInfo);
                }
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            }
            else if (clipInfo.maskType == ClipAnimationMaskType.CopyFromOther && clipInfo.MaskNeedsUpdating())
            {
                GUILayout.BeginHorizontal(EditorStyles.helpBox, new GUILayoutOption[0]);
                GUILayout.Label("Source Mask has changed since last import. It must be Updated", EditorStyles.wordWrappedMiniLabel, new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                GUILayout.BeginVertical();
                GUILayout.Space(5f);
                if (GUILayout.Button("Update Mask"))
                {
                    clipInfo.MaskToClip(clipInfo.maskSource);
                }
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            }
            if (ModelImporterClipEditor.m_MaskFoldout)
            {
                ++EditorGUI.indentLevel;
                this.m_MaskInspector.OnInspectorGUI();
            }
            EditorGUI.indentLevel = indentLevel;
        }
        private string MakeUniqueClipName(string name, int row)
        {
            string text = name;
            int    num  = 0;
            int    i;

            do
            {
                for (i = 0; i < this.m_ClipAnimations.arraySize; i++)
                {
                    AnimationClipInfoProperties animationClipInfoAtIndex = this.GetAnimationClipInfoAtIndex(i);
                    if (text == animationClipInfoAtIndex.name && row != i)
                    {
                        text = name + num.ToString();
                        num++;
                        break;
                    }
                }
            }while (i != this.m_ClipAnimations.arraySize);
            return(text);
        }
 private void AvatarMaskSettings(AnimationClipInfoProperties clipInfo)
 {
   if (clipInfo == null || !((UnityEngine.Object) this.m_AnimationClipEditor != (UnityEngine.Object) null))
     return;
   this.InitMask(clipInfo);
   int indentLevel = EditorGUI.indentLevel;
   bool changed = GUI.changed;
   ModelImporterClipEditor.m_MaskFoldout = EditorGUILayout.Foldout(ModelImporterClipEditor.m_MaskFoldout, ModelImporterClipEditor.styles.Mask);
   GUI.changed = changed;
   if (clipInfo.maskType == ClipAnimationMaskType.CreateFromThisModel && !this.m_MaskInspector.IsMaskUpToDate())
   {
     GUILayout.BeginHorizontal(EditorStyles.helpBox, new GUILayoutOption[0]);
     GUILayout.Label("Mask does not match hierarchy. Animation might not import correctly", EditorStyles.wordWrappedMiniLabel, new GUILayoutOption[0]);
     GUILayout.FlexibleSpace();
     GUILayout.BeginVertical();
     GUILayout.Space(5f);
     if (GUILayout.Button("Fix Mask"))
       this.SetTransformMaskFromReference(clipInfo);
     GUILayout.EndVertical();
     GUILayout.EndHorizontal();
   }
   else if (clipInfo.maskType == ClipAnimationMaskType.CopyFromOther && clipInfo.MaskNeedsUpdating())
   {
     GUILayout.BeginHorizontal(EditorStyles.helpBox, new GUILayoutOption[0]);
     GUILayout.Label("Source Mask has changed since last import. It must be Updated", EditorStyles.wordWrappedMiniLabel, new GUILayoutOption[0]);
     GUILayout.FlexibleSpace();
     GUILayout.BeginVertical();
     GUILayout.Space(5f);
     if (GUILayout.Button("Update Mask"))
       clipInfo.MaskToClip(clipInfo.maskSource);
     GUILayout.EndVertical();
     GUILayout.EndHorizontal();
   }
   if (ModelImporterClipEditor.m_MaskFoldout)
   {
     ++EditorGUI.indentLevel;
     this.m_MaskInspector.OnInspectorGUI();
   }
   EditorGUI.indentLevel = indentLevel;
 }
 public void UpdateEvent(AnimationClipInfoProperties info)
 {
     if (this.m_Event != null)
     {
         this.m_Event.clipInfo = info;
     }
 }
		private void UpdateEventsPopupClipInfo(AnimationClipInfoProperties info)
		{
			UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(typeof(AnimationEventPopup));
			AnimationEventPopup animationEventPopup = (array.Length <= 0) ? null : ((AnimationEventPopup)array[0]);
			if (animationEventPopup && animationEventPopup.clipInfo == this.m_ClipInfo)
			{
				animationEventPopup.clipInfo = info;
			}
		}
		public void ShowRange(AnimationClipInfoProperties info)
		{
			this.UpdateEventsPopupClipInfo(info);
			this.m_ClipInfo = info;
			info.AssignToPreviewClip(this.m_Clip);
		}
 private void SetTransformMaskFromReference(AnimationClipInfoProperties clipInfo)
 {
   string[] referenceTransformPaths = this.referenceTransformPaths;
   string[] humanTransforms = this.animationType != ModelImporterAnimationType.Human ? (string[]) null : AvatarMaskUtility.GetAvatarHumanTransform(this.serializedObject, referenceTransformPaths);
   AvatarMaskUtility.UpdateTransformMask(clipInfo.transformMaskProperty, referenceTransformPaths, humanTransforms);
 }
 private void SetBodyMaskDefaultValues(AnimationClipInfoProperties clipInfo)
 {
   SerializedProperty bodyMaskProperty = clipInfo.bodyMaskProperty;
   bodyMaskProperty.ClearArray();
   for (int index = 0; index < 13; ++index)
   {
     bodyMaskProperty.InsertArrayElementAtIndex(index);
     bodyMaskProperty.GetArrayElementAtIndex(index).intValue = 1;
   }
 }
 public void SelectEvent(AnimationEvent[] events, int index, AnimationClipInfoProperties clipInfo)
 {
   this.m_EventsSelected = new bool[events.Length];
   this.m_EventsSelected[index] = true;
   AnimationEventPopup.Edit(clipInfo, index);
 }
 public bool HandleEventManipulation(Rect rect, ref AnimationEvent[] events, AnimationClipInfoProperties clipInfo)
 {
   Texture image = EditorGUIUtility.IconContent("Animation.EventMarker").image;
   bool flag = false;
   Rect[] rectArray = new Rect[events.Length];
   Rect[] positions = new Rect[events.Length];
   int num1 = 1;
   int num2 = 0;
   for (int index = 0; index < events.Length; ++index)
   {
     AnimationEvent animationEvent = events[index];
     if (num2 == 0)
     {
       num1 = 1;
       while (index + num1 < events.Length && (double) events[index + num1].time == (double) animationEvent.time)
         ++num1;
       num2 = num1;
     }
     --num2;
     float num3 = Mathf.Floor(this.m_Timeline.TimeToPixel(animationEvent.time, rect));
     int num4 = 0;
     if (num1 > 1)
       num4 = Mathf.FloorToInt(Mathf.Max(0.0f, (float) Mathf.Min((num1 - 1) * (image.width - 1), (int) (1.0 / (double) this.m_Timeline.PixelDeltaToTime(rect) - (double) (image.width * 2))) - (float) ((image.width - 1) * num2)));
     Rect rect1 = new Rect(num3 + (float) num4 - (float) (image.width / 2), (rect.height - 10f) * (float) (num2 - num1 + 1) / (float) Mathf.Max(1, num1 - 1), (float) image.width, (float) image.height);
     rectArray[index] = rect1;
     positions[index] = rect1;
   }
   this.m_EventRects = new Rect[rectArray.Length];
   for (int index = 0; index < rectArray.Length; ++index)
     this.m_EventRects[index] = new Rect(rectArray[index].x + rect.x, rectArray[index].y + rect.y, rectArray[index].width, rectArray[index].height);
   if (this.m_EventsSelected == null || this.m_EventsSelected.Length != events.Length || this.m_EventsSelected.Length == 0)
   {
     this.m_EventsSelected = new bool[events.Length];
     AnimationEventPopup.ClosePopup();
   }
   Vector2 offset = Vector2.zero;
   int clickedIndex;
   float startSelect;
   float endSelect;
   switch (EditorGUIExt.MultiSelection(rect, positions, new GUIContent(image), rectArray, ref this.m_EventsSelected, (bool[]) null, out clickedIndex, out offset, out startSelect, out endSelect, GUIStyle.none))
   {
     case HighLevelEvent.ContextClick:
       GenericMenu genericMenu = new GenericMenu();
       genericMenu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), (object) new EventManipulationHandler.EventModificationContextMenuObjet(clipInfo, events[clickedIndex].time, clickedIndex));
       genericMenu.AddItem(new GUIContent("Delete Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), (object) new EventManipulationHandler.EventModificationContextMenuObjet(clipInfo, events[clickedIndex].time, clickedIndex));
       genericMenu.ShowAsContext();
       this.m_InstantTooltipText = (string) null;
       break;
     case HighLevelEvent.BeginDrag:
       EventManipulationHandler.m_EventsAtMouseDown = events;
       EventManipulationHandler.m_EventTimes = new float[events.Length];
       for (int index = 0; index < events.Length; ++index)
         EventManipulationHandler.m_EventTimes[index] = events[index].time;
       break;
     case HighLevelEvent.Drag:
       for (int index = events.Length - 1; index >= 0; --index)
       {
         if (this.m_EventsSelected[index])
           EventManipulationHandler.m_EventsAtMouseDown[index].time = Mathf.Clamp01(EventManipulationHandler.m_EventTimes[index] + offset.x / rect.width);
       }
       int[] numArray1 = new int[this.m_EventsSelected.Length];
       for (int index = 0; index < numArray1.Length; ++index)
         numArray1[index] = index;
       Array.Sort((Array) EventManipulationHandler.m_EventsAtMouseDown, (Array) numArray1, (IComparer) new AnimationEventTimeLine.EventComparer());
       bool[] flagArray = (bool[]) this.m_EventsSelected.Clone();
       float[] numArray2 = (float[]) EventManipulationHandler.m_EventTimes.Clone();
       for (int index = 0; index < numArray1.Length; ++index)
       {
         this.m_EventsSelected[index] = flagArray[numArray1[index]];
         EventManipulationHandler.m_EventTimes[index] = numArray2[numArray1[index]];
       }
       events = EventManipulationHandler.m_EventsAtMouseDown;
       flag = true;
       break;
     case HighLevelEvent.Delete:
       flag = this.DeleteEvents(ref events, this.m_EventsSelected);
       break;
     case HighLevelEvent.SelectionChanged:
       if (clickedIndex >= 0)
       {
         AnimationEventPopup.Edit(clipInfo, clickedIndex);
         break;
       }
       AnimationEventPopup.ClosePopup();
       break;
   }
   this.CheckRectsOnMouseMove(rect, events, rectArray);
   return flag;
 }
 public EventModificationContextMenuObjet(AnimationClipInfoProperties info, float time, int index)
 {
   this.m_Info = info;
   this.m_Time = time;
   this.m_Index = index;
 }
 private void UpdateEventsPopupClipInfo(AnimationClipInfoProperties info)
 {
   UnityEngine.Object[] objectsOfTypeAll = Resources.FindObjectsOfTypeAll(typeof (AnimationEventPopup));
   AnimationEventPopup animationEventPopup = objectsOfTypeAll.Length <= 0 ? (AnimationEventPopup) null : (AnimationEventPopup) objectsOfTypeAll[0];
   if (!(bool) ((UnityEngine.Object) animationEventPopup) || animationEventPopup.clipInfo != this.m_ClipInfo)
     return;
   animationEventPopup.clipInfo = info;
 }
		public bool HandleEventManipulation(Rect rect, ref AnimationEvent[] events, AnimationClipInfoProperties clipInfo)
		{
			Texture image = EditorGUIUtility.IconContent("Animation.EventMarker").image;
			bool result = false;
			Rect[] array = new Rect[events.Length];
			Rect[] array2 = new Rect[events.Length];
			int num = 1;
			int num2 = 0;
			for (int i = 0; i < events.Length; i++)
			{
				AnimationEvent animationEvent = events[i];
				if (num2 == 0)
				{
					num = 1;
					while (i + num < events.Length && events[i + num].time == animationEvent.time)
					{
						num++;
					}
					num2 = num;
				}
				num2--;
				float num3 = Mathf.Floor(this.m_Timeline.TimeToPixel(animationEvent.time, rect));
				int num4 = 0;
				if (num > 1)
				{
					float num5 = (float)Mathf.Min((num - 1) * (image.width - 1), (int)(1f / this.m_Timeline.PixelDeltaToTime(rect) - (float)(image.width * 2)));
					num4 = Mathf.FloorToInt(Mathf.Max(0f, num5 - (float)((image.width - 1) * num2)));
				}
				Rect rect2 = new Rect(num3 + (float)num4 - (float)(image.width / 2), (rect.height - 10f) * (float)(num2 - num + 1) / (float)Mathf.Max(1, num - 1), (float)image.width, (float)image.height);
				array[i] = rect2;
				array2[i] = rect2;
			}
			this.m_EventRects = new Rect[array.Length];
			for (int j = 0; j < array.Length; j++)
			{
				this.m_EventRects[j] = new Rect(array[j].x + rect.x, array[j].y + rect.y, array[j].width, array[j].height);
			}
			if (this.m_EventsSelected == null || this.m_EventsSelected.Length != events.Length || this.m_EventsSelected.Length == 0)
			{
				this.m_EventsSelected = new bool[events.Length];
				AnimationEventPopup.ClosePopup();
			}
			Vector2 zero = Vector2.zero;
			int num6;
			float num7;
			float num8;
			HighLevelEvent highLevelEvent = EditorGUIExt.MultiSelection(rect, array2, new GUIContent(image), array, ref this.m_EventsSelected, null, out num6, out zero, out num7, out num8, GUIStyleX.none);
			if (highLevelEvent != HighLevelEvent.None)
			{
				switch (highLevelEvent)
				{
				case HighLevelEvent.ContextClick:
				{
					GenericMenu genericMenu = new GenericMenu();
					genericMenu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), new EventManipulationHandler.EventModificationContextMenuObjet(clipInfo, events[num6].time, num6));
					genericMenu.AddItem(new GUIContent("Delete Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), new EventManipulationHandler.EventModificationContextMenuObjet(clipInfo, events[num6].time, num6));
					genericMenu.ShowAsContext();
					this.m_InstantTooltipText = null;
					break;
				}
				case HighLevelEvent.BeginDrag:
					EventManipulationHandler.m_EventsAtMouseDown = events;
					EventManipulationHandler.m_EventTimes = new float[events.Length];
					for (int k = 0; k < events.Length; k++)
					{
						EventManipulationHandler.m_EventTimes[k] = events[k].time;
					}
					break;
				case HighLevelEvent.Drag:
				{
					for (int l = events.Length - 1; l >= 0; l--)
					{
						if (this.m_EventsSelected[l])
						{
							AnimationEvent animationEvent2 = EventManipulationHandler.m_EventsAtMouseDown[l];
							animationEvent2.time = Mathf.Clamp01(EventManipulationHandler.m_EventTimes[l] + zero.x / rect.width);
						}
					}
					int[] array3 = new int[this.m_EventsSelected.Length];
					for (int m = 0; m < array3.Length; m++)
					{
						array3[m] = m;
					}
					Array.Sort(EventManipulationHandler.m_EventsAtMouseDown, array3, new AnimationEventTimeLine.EventComparer());
					bool[] array4 = (bool[])this.m_EventsSelected.Clone();
					float[] array5 = (float[])EventManipulationHandler.m_EventTimes.Clone();
					for (int n = 0; n < array3.Length; n++)
					{
						this.m_EventsSelected[n] = array4[array3[n]];
						EventManipulationHandler.m_EventTimes[n] = array5[array3[n]];
					}
					events = EventManipulationHandler.m_EventsAtMouseDown;
					result = true;
					break;
				}
				case HighLevelEvent.Delete:
					result = this.DeleteEvents(ref events, this.m_EventsSelected);
					break;
				case HighLevelEvent.SelectionChanged:
					if (num6 >= 0)
					{
						AnimationEventPopup.Edit(clipInfo, num6);
					}
					else
					{
						AnimationEventPopup.ClosePopup();
					}
					break;
				}
			}
			this.CheckRectsOnMouseMove(rect, events, array);
			return result;
		}
        public bool HandleEventManipulation(Rect rect, ref AnimationEvent[] events, AnimationClipInfoProperties clipInfo)
        {
            int num8;
            float num9;
            float num10;
            Texture image = EditorGUIUtility.IconContent("Animation.EventMarker").image;
            bool flag = false;
            Rect[] hitPositions = new Rect[events.Length];
            Rect[] positions = new Rect[events.Length];
            int num = 1;
            int num2 = 0;
            for (int i = 0; i < events.Length; i++)
            {
                AnimationEvent event2 = events[i];
                if (num2 == 0)
                {
                    num = 1;
                    while (((i + num) < events.Length) && (events[i + num].time == event2.time))
                    {
                        num++;
                    }
                    num2 = num;
                }
                num2--;
                float num4 = Mathf.Floor(this.m_Timeline.TimeToPixel(event2.time, rect));
                int num5 = 0;
                if (num > 1)
                {
                    float num6 = Mathf.Min((int) ((num - 1) * (image.width - 1)), (int) (((int) (1f / this.m_Timeline.PixelDeltaToTime(rect))) - (image.width * 2)));
                    num5 = Mathf.FloorToInt(Mathf.Max((float) 0f, (float) (num6 - ((image.width - 1) * num2))));
                }
                Rect rect2 = new Rect((num4 + num5) - (image.width / 2), ((rect.height - 10f) * ((num2 - num) + 1)) / ((float) Mathf.Max(1, num - 1)), (float) image.width, (float) image.height);
                hitPositions[i] = rect2;
                positions[i] = rect2;
            }
            this.m_EventRects = new Rect[hitPositions.Length];
            for (int j = 0; j < hitPositions.Length; j++)
            {
                this.m_EventRects[j] = new Rect(hitPositions[j].x + rect.x, hitPositions[j].y + rect.y, hitPositions[j].width, hitPositions[j].height);
            }
            if (((this.m_EventsSelected == null) || (this.m_EventsSelected.Length != events.Length)) || (this.m_EventsSelected.Length == 0))
            {
                this.m_EventsSelected = new bool[events.Length];
                this.m_Event = null;
            }
            Vector2 zero = Vector2.zero;
            switch (EditorGUIExt.MultiSelection(rect, positions, new GUIContent(image), hitPositions, ref this.m_EventsSelected, null, out num8, out zero, out num9, out num10, GUIStyle.none))
            {
                case HighLevelEvent.ContextClick:
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), new EventModificationContextMenuObjet(clipInfo, events[num8].time, num8));
                    menu.AddItem(new GUIContent("Delete Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), new EventModificationContextMenuObjet(clipInfo, events[num8].time, num8));
                    menu.ShowAsContext();
                    this.m_InstantTooltipText = null;
                    break;
                }
                case HighLevelEvent.BeginDrag:
                    m_EventsAtMouseDown = events;
                    m_EventTimes = new float[events.Length];
                    for (int k = 0; k < events.Length; k++)
                    {
                        m_EventTimes[k] = events[k].time;
                    }
                    break;

                case HighLevelEvent.Drag:
                {
                    for (int m = events.Length - 1; m >= 0; m--)
                    {
                        if (this.m_EventsSelected[m])
                        {
                            AnimationEvent event4 = m_EventsAtMouseDown[m];
                            event4.time = Mathf.Clamp01(m_EventTimes[m] + (zero.x / rect.width));
                        }
                    }
                    int[] items = new int[this.m_EventsSelected.Length];
                    for (int n = 0; n < items.Length; n++)
                    {
                        items[n] = n;
                    }
                    Array.Sort(m_EventsAtMouseDown, items, new AnimationEventTimeLine.EventComparer());
                    bool[] flagArray = (bool[]) this.m_EventsSelected.Clone();
                    float[] numArray2 = (float[]) m_EventTimes.Clone();
                    for (int num14 = 0; num14 < items.Length; num14++)
                    {
                        this.m_EventsSelected[num14] = flagArray[items[num14]];
                        m_EventTimes[num14] = numArray2[items[num14]];
                    }
                    events = m_EventsAtMouseDown;
                    flag = true;
                    break;
                }
                case HighLevelEvent.Delete:
                    flag = this.DeleteEvents(ref events, this.m_EventsSelected);
                    break;

                case HighLevelEvent.SelectionChanged:
                    this.m_Event = (num8 < 0) ? null : AnimationWindowEvent.Edit(clipInfo, num8);
                    break;
            }
            this.CheckRectsOnMouseMove(rect, events, hitPositions);
            return flag;
        }
 private void InitMask(AnimationClipInfoProperties clipInfo)
 {
   if (!((UnityEngine.Object) this.m_Mask == (UnityEngine.Object) null))
     return;
   AnimationClip target = this.m_AnimationClipEditor.target as AnimationClip;
   this.m_Mask = new AvatarMask();
   this.m_MaskInspector = (AvatarMaskInspector) Editor.CreateEditor((UnityEngine.Object) this.m_Mask);
   this.m_MaskInspector.canImport = false;
   this.m_MaskInspector.showBody = target.isHumanMotion;
   this.m_MaskInspector.clipInfo = clipInfo;
 }
Ejemplo n.º 45
0
 private void SetupTakeNameAndFrames(AnimationClipInfoProperties info, TakeInfo takeInfo)
 {
     info.takeName = takeInfo.name;
     info.firstFrame = (int) Mathf.Round(takeInfo.bakeStartTime * takeInfo.sampleRate);
     info.lastFrame = (int) Mathf.Round(takeInfo.bakeStopTime * takeInfo.sampleRate);
 }
Ejemplo n.º 46
0
 private void UpdateEventsPopupClipInfo(AnimationClipInfoProperties info)
 {
     UnityEngine.Object[] objArray = Resources.FindObjectsOfTypeAll(typeof(AnimationEventPopup));
     AnimationEventPopup popup = (objArray.Length <= 0) ? null : ((AnimationEventPopup) objArray[0]);
     if ((popup != null) && (popup.clipInfo == this.m_ClipInfo))
     {
         popup.clipInfo = info;
     }
 }