GetAnimationClips() private method

private GetAnimationClips ( Animation component ) : UnityEngine.AnimationClip[]
component UnityEngine.Animation
return UnityEngine.AnimationClip[]
コード例 #1
0
        private void SetupWizardOnGUI(Rect position)
        {
            Rect position1 = new Rect(position.x, position.y, position.width - 15f, position.height - 15f);

            GUI.BeginClip(position1);
            GUI.enabled = true;
            this.m_State.showCurveEditor = false;
            this.m_State.timeArea        = (TimeArea)this.m_DopeSheet;
            this.m_State.timeArea.SetShownHRangeInsideMargins(0.0f, 1f);
            if ((bool)((UnityEngine.Object)Selection.activeGameObject) && !EditorUtility.IsPersistent((UnityEngine.Object)Selection.activeGameObject))
            {
                string     str       = (bool)((UnityEngine.Object) this.m_State.activeRootGameObject) || (bool)((UnityEngine.Object) this.m_State.activeAnimationClip) ? AnimationWindowStyles.animationClip.text : AnimationWindowStyles.animatorAndAnimationClip.text;
                GUIContent content   = GUIContent.Temp(string.Format(AnimationWindowStyles.formatIsMissing.text, (object)Selection.activeGameObject.name, (object)str));
                Vector2    vector2   = GUI.skin.label.CalcSize(content);
                Rect       position2 = new Rect((float)((double)position1.width * 0.5 - (double)vector2.x * 0.5), (float)((double)position1.height * 0.5 - (double)vector2.y * 0.5), vector2.x, vector2.y);
                GUI.Label(position2, content);
                if (GUI.Button(new Rect((float)((double)position1.width * 0.5 - 35.0), position2.yMax + 3f, 70f, 20f), AnimationWindowStyles.create) && AnimationWindowUtility.InitializeGameobjectForAnimation(Selection.activeGameObject))
                {
                    this.m_State.activeAnimationClip = AnimationUtility.GetAnimationClips(AnimationWindowUtility.GetClosestAnimationPlayerComponentInParents(Selection.activeGameObject.transform).gameObject)[0];
                    this.m_State.recording           = true;
                    this.m_State.currentTime         = 0.0f;
                    this.m_State.ResampleAnimation();
                }
            }
            else
            {
                Color color = GUI.color;
                GUI.color = Color.gray;
                Vector2 vector2 = GUI.skin.label.CalcSize(AnimationWindowStyles.noAnimatableObjectSelectedText);
                GUI.Label(new Rect((float)((double)position1.width * 0.5 - (double)vector2.x * 0.5), (float)((double)position1.height * 0.5 - (double)vector2.y * 0.5), vector2.x, vector2.y), AnimationWindowStyles.noAnimatableObjectSelectedText);
                GUI.color = color;
            }
            GUI.EndClip();
            GUI.enabled = false;
        }
コード例 #2
0
        private bool ShouldUpdateSelection(AnimationWindowSelectionItem selectedItem)
        {
            if (selectedItem.rootGameObject == null)
            {
                return(true);
            }
            AnimationWindowSelectionItem currentlySelectedItem = this.m_AnimEditor.selectedItem;

            if (!(currentlySelectedItem != null))
            {
                return(true);
            }
            if (selectedItem.rootGameObject != currentlySelectedItem.rootGameObject)
            {
                return(true);
            }
            if (currentlySelectedItem.animationClip == null)
            {
                return(true);
            }
            if (currentlySelectedItem.rootGameObject != null)
            {
                AnimationClip[] animationClips = AnimationUtility.GetAnimationClips(currentlySelectedItem.rootGameObject);
                if (!Array.Exists <AnimationClip>(animationClips, (AnimationClip x) => x == currentlySelectedItem.animationClip))
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #3
0
        private void SetupWizardOnGUI(Rect position)
        {
            GUI.Label(position, GUIContent.none, AnimationWindowStyles.dopeSheetBackground);

            Rect positionWithoutScrollBar = new Rect(position.x, position.y, position.width - kSliderThickness, position.height - kSliderThickness);

            GUI.BeginClip(positionWithoutScrollBar);
            GUI.enabled = true;

            m_State.showCurveEditor = false;
            m_State.timeArea        = m_DopeSheet;
            m_State.timeArea.SetShownHRangeInsideMargins(0f, 1f);

            bool animatableObject = m_State.activeGameObject && !EditorUtility.IsPersistent(m_State.activeGameObject);

            if (animatableObject)
            {
                var missingObjects = (!m_State.activeRootGameObject && !m_State.activeAnimationClip) ? AnimationWindowStyles.animatorAndAnimationClip.text : AnimationWindowStyles.animationClip.text;

                string txt = String.Format(AnimationWindowStyles.formatIsMissing.text, m_State.activeGameObject.name, missingObjects);

                const float buttonWidth   = 70f;
                const float buttonHeight  = 20f;
                const float buttonPadding = 3f;

                GUIContent textContent = GUIContent.Temp(txt);
                Vector2    textSize    = GUI.skin.label.CalcSize(textContent);
                Rect       labelRect   = new Rect(positionWithoutScrollBar.width * .5f - textSize.x * .5f, positionWithoutScrollBar.height * .5f - textSize.y * .5f, textSize.x, textSize.y);
                GUI.Label(labelRect, textContent);

                Rect buttonRect = new Rect(positionWithoutScrollBar.width * .5f - buttonWidth * .5f, labelRect.yMax + buttonPadding, buttonWidth, buttonHeight);

                if (GUI.Button(buttonRect, AnimationWindowStyles.create))
                {
                    if (AnimationWindowUtility.InitializeGameobjectForAnimation(m_State.activeGameObject))
                    {
                        Component animationPlayer = AnimationWindowUtility.GetClosestAnimationPlayerComponentInParents(m_State.activeGameObject.transform);
                        m_State.activeAnimationClip = AnimationUtility.GetAnimationClips(animationPlayer.gameObject)[0];
                    }

                    //  Layout has changed, bail out now.
                    EditorGUIUtility.ExitGUI();
                }
            }
            else
            {
                Color oldColor = GUI.color;
                GUI.color = Color.gray;
                Vector2 textSize  = GUI.skin.label.CalcSize(AnimationWindowStyles.noAnimatableObjectSelectedText);
                Rect    labelRect = new Rect(positionWithoutScrollBar.width * .5f - textSize.x * .5f, positionWithoutScrollBar.height * .5f - textSize.y * .5f, textSize.x, textSize.y);
                GUI.Label(labelRect, AnimationWindowStyles.noAnimatableObjectSelectedText);
                GUI.color = oldColor;
            }
            GUI.EndClip();
            GUI.enabled = false; // Reset state to false. It's always false originally for SetupWizardOnGUI.
        }
コード例 #4
0
 private AnimationClip[] GetOrderedClipList()
 {
     AnimationClip[] array = new AnimationClip[0];
     if (this.state.activeRootGameObject != null)
     {
         array = AnimationUtility.GetAnimationClips(this.state.activeRootGameObject);
     }
     Array.Sort <AnimationClip>(array, (AnimationClip clip1, AnimationClip clip2) => CurveUtility.GetClipName(clip1).CompareTo(CurveUtility.GetClipName(clip2)));
     return(array);
 }
コード例 #5
0
 private AnimationClip IndexToClip(int index)
 {
     if ((UnityEngine.Object) this.state.activeRootGameObject != (UnityEngine.Object)null)
     {
         AnimationClip[] animationClips = AnimationUtility.GetAnimationClips(this.state.activeRootGameObject);
         if (index >= 0 && index < animationClips.Length)
         {
             return(AnimationUtility.GetAnimationClips(this.state.activeRootGameObject)[index]);
         }
     }
     return((AnimationClip)null);
 }
コード例 #6
0
        private AnimationClip[] GetOrderedClipList()
        {
            AnimationClip[] clips = new AnimationClip[0];
            if (state.activeRootGameObject != null)
            {
                clips = AnimationUtility.GetAnimationClips(state.activeRootGameObject);
            }

            Array.Sort(clips, (AnimationClip clip1, AnimationClip clip2) => CurveUtility.GetClipName(clip1).CompareTo(CurveUtility.GetClipName(clip2)));

            return(clips);
        }
コード例 #7
0
 private AnimationClip IndexToClip(int index)
 {
     if (this.state.activeRootGameObject != null)
     {
         AnimationClip[] animationClips = AnimationUtility.GetAnimationClips(this.state.activeRootGameObject);
         if ((index >= 0) && (index < animationClips.Length))
         {
             return(AnimationUtility.GetAnimationClips(this.state.activeRootGameObject)[index]);
         }
     }
     return(null);
 }
コード例 #8
0
        private AnimationClip[] GetOrderedClipList()
        {
            AnimationClip[] clips = new AnimationClip[0];
            if (state.activeRootGameObject != null)
            {
                clips = AnimationUtility.GetAnimationClips(state.activeRootGameObject);
            }

            //Using AlphaNum/Natural Compare to sort clips
            Array.Sort(clips, (AnimationClip clip1, AnimationClip clip2) => EditorUtility.NaturalCompareObjectNames(clip1, clip2));

            return(clips);
        }
コード例 #9
0
 private AnimationClip AddClipToAnimationComponent(AnimationClip newClip)
 {
     if (this.animatedObject.GetComponent <Animation>() == null)
     {
         Animation animation = this.animatedObject.AddComponent(typeof(Animation)) as Animation;
         animation.clip = newClip;
     }
     AnimationClip[] animationClips = AnimationUtility.GetAnimationClips(this.animatedObject);
     Array.Resize <AnimationClip>(ref animationClips, animationClips.Length + 1);
     animationClips[animationClips.Length - 1] = newClip;
     AnimationUtility.SetAnimationClips(this.animatedObject.GetComponent <Animation>(), animationClips);
     return(newClip);
 }
コード例 #10
0
 private string[] GetClipNames()
 {
     AnimationClip[] animationClips = new AnimationClip[0];
     if ((this.state.activeRootGameObject != null) && (this.state.activeAnimationClip != null))
     {
         animationClips = AnimationUtility.GetAnimationClips(this.state.activeRootGameObject);
     }
     string[] strArray = new string[animationClips.Length];
     for (int i = 0; i < animationClips.Length; i++)
     {
         strArray[i] = CurveUtility.GetClipName(animationClips[i]);
     }
     return(strArray);
 }
コード例 #11
0
 private string[] GetClipNames()
 {
     AnimationClip[] array = new AnimationClip[0];
     if (this.state.activeRootGameObject != null && this.state.activeAnimationClip != null)
     {
         array = AnimationUtility.GetAnimationClips(this.state.activeRootGameObject);
     }
     string[] array2 = new string[array.Length];
     for (int i = 0; i < array.Length; i++)
     {
         array2[i] = CurveUtility.GetClipName(array[i]);
     }
     return(array2);
 }
コード例 #12
0
 private int GetIndexOfClip(AnimationClip clip)
 {
     if (this.hasAnimationComponent)
     {
         AnimationClip[] animationClips = AnimationUtility.GetAnimationClips(this.animatedObject);
         for (int i = 0; i < animationClips.Length; i++)
         {
             if (animationClips[i] == clip)
             {
                 return(i);
             }
         }
     }
     return(-1);
 }
コード例 #13
0
 private int ClipToIndex(AnimationClip clip)
 {
     if (this.state.activeRootGameObject != null)
     {
         int num = 0;
         foreach (AnimationClip clip2 in AnimationUtility.GetAnimationClips(this.state.activeRootGameObject))
         {
             if (clip == clip2)
             {
                 return(num);
             }
             num++;
         }
     }
     return(0);
 }
コード例 #14
0
        private AnimationClip IndexToClip(int index)
        {
            AnimationClip result;

            if (this.state.activeRootGameObject != null)
            {
                AnimationClip[] animationClips = AnimationUtility.GetAnimationClips(this.state.activeRootGameObject);
                if (index >= 0 && index < animationClips.Length)
                {
                    result = AnimationUtility.GetAnimationClips(this.state.activeRootGameObject)[index];
                    return(result);
                }
            }
            result = null;
            return(result);
        }
コード例 #15
0
 private int ClipToIndex(AnimationClip clip)
 {
     if ((UnityEngine.Object) this.state.activeRootGameObject != (UnityEngine.Object)null)
     {
         int num = 0;
         foreach (AnimationClip animationClip in AnimationUtility.GetAnimationClips(this.state.activeRootGameObject))
         {
             if ((UnityEngine.Object)clip == (UnityEngine.Object)animationClip)
             {
                 return(num);
             }
             ++num;
         }
     }
     return(0);
 }
コード例 #16
0
        private bool ShouldUpdateSelection(GameObjectSelectionItem selectedItem)
        {
            bool result;

            if (this.m_AnimEditor.locked)
            {
                result = false;
            }
            else if (selectedItem.rootGameObject == null)
            {
                result = true;
            }
            else
            {
                AnimationWindowSelectionItem currentlySelectedItem = this.m_AnimEditor.selectedItem;
                if (currentlySelectedItem != null)
                {
                    if (selectedItem.rootGameObject != currentlySelectedItem.rootGameObject)
                    {
                        result = true;
                    }
                    else if (currentlySelectedItem.animationClip == null)
                    {
                        result = true;
                    }
                    else
                    {
                        if (currentlySelectedItem.rootGameObject != null)
                        {
                            AnimationClip[] animationClips = AnimationUtility.GetAnimationClips(currentlySelectedItem.rootGameObject);
                            if (!Array.Exists <AnimationClip>(animationClips, (AnimationClip x) => x == currentlySelectedItem.animationClip))
                            {
                                result = true;
                                return(result);
                            }
                        }
                        result = false;
                    }
                }
                else
                {
                    result = true;
                }
            }
            return(result);
        }
コード例 #17
0
 private AnimationClip GetClipAtIndex(int index)
 {
     if (!this.hasAnimationComponent)
     {
         return(null);
     }
     AnimationClip[] animationClips = AnimationUtility.GetAnimationClips(this.animatedObject);
     if (index == -1)
     {
         return(null);
     }
     if (index >= animationClips.Length)
     {
         return(null);
     }
     return(animationClips[index]);
 }
コード例 #18
0
        private void SetupWizardOnGUI(Rect position)
        {
            GUI.Label(position, GUIContent.none, AnimationWindowStyles.dopeSheetBackground);
            Rect position2 = new Rect(position.x, position.y, position.width - 15f, position.height - 15f);

            GUI.BeginClip(position2);
            GUI.enabled = true;
            this.m_State.showCurveEditor = false;
            this.m_State.timeArea        = this.m_DopeSheet;
            this.m_State.timeArea.SetShownHRangeInsideMargins(0f, 1f);
            bool flag = this.m_State.activeGameObject && !EditorUtility.IsPersistent(this.m_State.activeGameObject);

            if (flag)
            {
                string     arg       = (this.m_State.activeRootGameObject || this.m_State.activeAnimationClip) ? AnimationWindowStyles.animationClip.text : AnimationWindowStyles.animatorAndAnimationClip.text;
                string     t         = string.Format(AnimationWindowStyles.formatIsMissing.text, this.m_State.activeGameObject.name, arg);
                GUIContent content   = GUIContent.Temp(t);
                Vector2    vector    = GUI.skin.label.CalcSize(content);
                Rect       position3 = new Rect(position2.width * 0.5f - vector.x * 0.5f, position2.height * 0.5f - vector.y * 0.5f, vector.x, vector.y);
                GUI.Label(position3, content);
                Rect position4 = new Rect(position2.width * 0.5f - 35f, position3.yMax + 3f, 70f, 20f);
                if (GUI.Button(position4, AnimationWindowStyles.create))
                {
                    if (AnimationWindowUtility.InitializeGameobjectForAnimation(this.m_State.activeGameObject))
                    {
                        Component closestAnimationPlayerComponentInParents = AnimationWindowUtility.GetClosestAnimationPlayerComponentInParents(this.m_State.activeGameObject.transform);
                        this.m_State.selection.UpdateClip(this.m_State.selectedItem, AnimationUtility.GetAnimationClips(closestAnimationPlayerComponentInParents.gameObject)[0]);
                        this.m_State.recording   = true;
                        this.m_State.currentTime = 0f;
                        this.m_State.ResampleAnimation();
                        GUIUtility.ExitGUI();
                    }
                }
            }
            else
            {
                Color color = GUI.color;
                GUI.color = Color.gray;
                Vector2 vector2   = GUI.skin.label.CalcSize(AnimationWindowStyles.noAnimatableObjectSelectedText);
                Rect    position5 = new Rect(position2.width * 0.5f - vector2.x * 0.5f, position2.height * 0.5f - vector2.y * 0.5f, vector2.x, vector2.y);
                GUI.Label(position5, AnimationWindowStyles.noAnimatableObjectSelectedText);
                GUI.color = color;
            }
            GUI.EndClip();
            GUI.enabled = false;
        }
コード例 #19
0
 private int ClipToIndex(AnimationClip clip)
 {
     if (this.state.activeRootGameObject != null)
     {
         int             num            = 0;
         AnimationClip[] animationClips = AnimationUtility.GetAnimationClips(this.state.activeRootGameObject);
         for (int i = 0; i < animationClips.Length; i++)
         {
             AnimationClip y = animationClips[i];
             if (clip == y)
             {
                 return(num);
             }
             num++;
         }
     }
     return(0);
 }
コード例 #20
0
 public string[] GetClipNames()
 {
     string[] array;
     if (this.hasAnimationComponent)
     {
         AnimationClip[] animationClips = AnimationUtility.GetAnimationClips(this.animatedObject);
         array = new string[animationClips.Length];
         for (int i = 0; i < animationClips.Length; i++)
         {
             array[i] = CurveUtility.GetClipName(animationClips[i]);
         }
     }
     else
     {
         array = new string[0];
     }
     return(array);
 }
コード例 #21
0
        private bool ShouldUpdateGameObjectSelection(GameObjectSelectionItem selectedItem)
        {
            if (m_LockTracker.isLocked)
            {
                return(false);
            }

            if (state.linkedWithSequencer)
            {
                return(false);
            }

            // Selected game object with no animation player.
            if (selectedItem.rootGameObject == null)
            {
                return(true);
            }

            AnimationWindowSelectionItem currentSelection = m_AnimEditor.selection;

            // Game object holding animation player has changed.  Update selection.
            if (selectedItem.rootGameObject != currentSelection.rootGameObject)
            {
                return(true);
            }

            // No clip in current selection, favour new selection.
            if (currentSelection.animationClip == null)
            {
                return(true);
            }

            // Make sure that animation clip is still referenced in animation player.
            if (currentSelection.rootGameObject != null)
            {
                AnimationClip[] allClips = AnimationUtility.GetAnimationClips(currentSelection.rootGameObject);
                if (!Array.Exists(allClips, x => x == currentSelection.animationClip))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #22
0
        private AnimationWindowSelectionItem BuildSelection(GameObject gameObject)
        {
            StandaloneSelectionItem selectedItem = StandaloneSelectionItem.Create();

            selectedItem.gameObject    = gameObject;
            selectedItem.animationClip = null;
            selectedItem.timeOffset    = 0f;
            selectedItem.id            = 0;
            if (selectedItem.rootGameObject != null)
            {
                AnimationClip[] animationClips = AnimationUtility.GetAnimationClips(selectedItem.rootGameObject);
                if (selectedItem.animationClip == null && selectedItem.gameObject != null)
                {
                    selectedItem.animationClip = ((animationClips.Length <= 0) ? null : animationClips[0]);
                }
                else if (!Array.Exists <AnimationClip>(animationClips, (AnimationClip x) => x == selectedItem.animationClip))
                {
                    selectedItem.animationClip = ((animationClips.Length <= 0) ? null : animationClips[0]);
                }
            }
            return(selectedItem);
        }
コード例 #23
0
 private string[] GetClipNames()
 {
     AnimationClip[] animationClipArray = new AnimationClip[0];
     if (this.state.clipOnlyMode)
     {
         animationClipArray = new AnimationClip[1]
         {
             this.state.activeAnimationClip
         }
     }
     ;
     else if ((UnityEngine.Object) this.state.activeRootGameObject != (UnityEngine.Object)null)
     {
         animationClipArray = AnimationUtility.GetAnimationClips(this.state.activeRootGameObject);
     }
     string[] strArray = new string[animationClipArray.Length];
     for (int index = 0; index < animationClipArray.Length; ++index)
     {
         strArray[index] = CurveUtility.GetClipName(animationClipArray[index]);
     }
     return(strArray);
 }
コード例 #24
0
 private void RefreshChosenClip(SerializedStringTable chosenClip)
 {
     if (this.hasAnimationComponent)
     {
         string stringArrayHashCode = AnimationSelection.GetStringArrayHashCode(this.GetClipNames());
         if (!chosenClip.Contains(stringArrayHashCode))
         {
             this.m_Clip = null;
             AnimationClip[] animationClips = AnimationUtility.GetAnimationClips(this.animatedObject);
             for (int i = 0; i < animationClips.Length; i++)
             {
                 if (animationClips[i] != null)
                 {
                     this.m_Clip = animationClips[i];
                     break;
                 }
             }
         }
         else
         {
             this.m_Clip = this.GetClipAtIndex(chosenClip.Get(stringArrayHashCode));
         }
     }
 }
コード例 #25
0
 public static AnimationClip[] GetAnimationClips(Animation component)
 {
     return(AnimationUtility.GetAnimationClips(component.gameObject));
 }