public void OnGUI()
        {
            if (state.selection.canChangeAnimationClip)
            {
                var newClip = DoClipPopup(state.activeAnimationClip, AnimationWindowStyles.animClipToolbarPopup);
                if (state.selection.canCreateClips)
                {
                    addCI.SetSourceView();
                    if (GUILayout.Button(new GUIContent("+", "Create New Clip..."), EditorStyles.toolbarButton))
                    {
                        newClip = AnimationWindowUtility.CreateNewClip(state.selection.rootGameObject.name);
                        if (newClip)
                        {
                            AnimationWindowUtility.AddClipToAnimationPlayerComponent(state.activeAnimationPlayer, newClip);
                            addCI.selectedClip = newClip;
                            addCI.SendEvent();
                        }
                    }
                }
                if (state.activeAnimationClip != newClip)
                {
                    state.activeAnimationClip = newClip;

                    //  Layout has changed, bail out now.
                    EditorGUIUtility.ExitGUI();
                }
            }
            else if (state.activeAnimationClip != null)
            {
                Rect r = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight, AnimationWindowStyles.toolbarLabel);
                EditorGUI.LabelField(r, CurveUtility.GetClipName(state.activeAnimationClip), AnimationWindowStyles.toolbarLabel);
            }
        }
        // (case 1029160) Modified version of EditorGUI.DoPopup to fit large data list query.
        private AnimationClip DoClipPopup(AnimationClip clip, GUIStyle style)
        {
            Rect position = EditorGUILayout.GetControlRect(false, EditorGUI.kSingleLineHeight, style);

            clip = popupCI.GetSelectedClipForControl(clip);
            clip = addCI.GetSelectedClipForControl(clip);

            Font originalFont = style.font;

            if (originalFont && EditorGUIUtility.GetBoldDefaultFont() && originalFont == EditorStyles.miniFont)
            {
                style.font = EditorStyles.miniBoldFont;
            }

            GUIContent buttonContent = EditorGUIUtility.TempContent(CurveUtility.GetClipName(clip));

            buttonContent.tooltip = AssetDatabase.GetAssetPath(clip);

            if (GUI.Button(position, buttonContent, style))
            {
                DisplayClipMenu(position, clip);
            }

            return(clip);
        }
Exemple #3
0
        public void SetBoth(TangentMode mode, List <KeyIdentifier> keysToSet)
        {
            List <ChangedCurve> changedCurves = new List <ChangedCurve>();

            foreach (KeyIdentifier keyToSet in keysToSet)
            {
                AnimationCurve animationCurve = keyToSet.curve;
                Keyframe       key            = keyToSet.keyframe;
                AnimationUtility.SetKeyBroken(ref key, false);
                AnimationUtility.SetKeyRightTangentMode(ref key, mode);
                AnimationUtility.SetKeyLeftTangentMode(ref key, mode);

                // Smooth Tangents based on neighboring nodes
                // Note: not needed since the UpdateTangentsFromModeSurrounding call below will handle it
                //if (mode == TangentMode.ClampedAuto) animationCurve.SmoothTangents(keyToSet.key, 0.0F);
                // Smooth tangents based on existing tangents
                if (mode == TangentMode.Free)
                {
                    float slope = CurveUtility.CalculateSmoothTangent(key);
                    key.inTangent  = slope;
                    key.outTangent = slope;
                }
                animationCurve.MoveKey(keyToSet.key, key);
                AnimationUtility.UpdateTangentsFromModeSurrounding(animationCurve, keyToSet.key);

                ChangedCurve changedCurve = new ChangedCurve(animationCurve, keyToSet.curveId, keyToSet.binding);
                if (!changedCurves.Contains(changedCurve))
                {
                    changedCurves.Add(changedCurve);
                }
            }

            updater.UpdateCurves(changedCurves, "Set Tangents");
        }
        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);
        }