Esempio n. 1
0
        static void  ShowWindow()
        {
            UIAnimatorWindow window = EditorWindow.GetWindow <UIAnimatorWindow>(EditorPrefs.GetBool("UIAnimationWindowDetachable", false), "Animation Easing", true);

            window.minSize = new Vector2(windowWidth, 50);
            window.maxSize = new Vector2(windowWidth, 400);
        }
Esempio n. 2
0
        void OnGUI()
        {
            GUILayout.BeginArea(new Rect(7, 0, this.position.width - 14, this.position.height));
            EditorGUI.BeginChangeCheck();
            GUILayout.Space(5);
            GUILayout.Label("Add easing to UI Animation", EditorStyles.boldLabel);

            detachable = EditorGUILayout.Toggle("Detachable", detachable, GUILayout.Height(20));
            if (GUI.changed)
            {
                EditorPrefs.SetBool("UIAnimationWindowDetachable", detachable);
                this.Close();
                UIAnimatorWindow.ShowWindow();
            }
            clip = EditorGUILayout.ObjectField("Animation Clip:", clip, typeof(AnimationClip), true, GUILayout.Height(16)) as AnimationClip;
            GUILayout.Space(5);
            if (clip == null)
            {
                EditorGUILayout.HelpBox("Select An Animation Clip!", MessageType.Info);
                valid = false;
                End();
                return;
            }
            //if the user changed the clip get the new bindings
            if (clip != oldclip)
            {
                refreshClipData(clip);
            }
            if (properties.Length > 0)
            {
                valid = true;
                //getting the selected Property from the user
                propertiesindex = EditorGUILayout.Popup("Property:", propertiesindex, displayableProperties, GUILayout.Height(25));
                propertyName    = properties[propertiesindex];

                originalCurve = EditorGUILayout.CurveField("Current Curve: ", curveByPropertyName(propertyName), Color.magenta, new Rect(), GUILayout.Height(windowWidth / 3));

                startkeyframe = EditorGUILayout.IntSlider("Start from Keyframe:", startkeyframe, 0, originalCurve.keys.Length - 1, GUILayout.Height(17));
                endkeyframe   = EditorGUILayout.IntSlider("End with Keyframe:", endkeyframe, 0, originalCurve.keys.Length - 1, GUILayout.Height(17));
                if (startkeyframe >= endkeyframe)
                {
                    EditorGUILayout.HelpBox("No Keyframes would be affected!", MessageType.Warning);
                    valid = false;
                }
                GUILayout.Space(5);
                GUILayout.Label("Easing:", EditorStyles.label);
                easeType = (EasingTypes)EditorGUILayout.EnumPopup(easeType, GUILayout.Height(18));
                GUILayout.Space(5);
                keyframes = EditorGUILayout.IntField("Number of Keyframes:", keyframes, GUILayout.Height(17));
                if (keyframes < 2)
                {
                    EditorGUILayout.HelpBox("At Least 2 Keyframes are needed!", MessageType.Error);
                    valid = false;
                }
                keyframeReductionTolerance = EditorGUILayout.FloatField("Reduction Tolerance:", keyframeReductionTolerance, GUILayout.Height(17));

                if (valid)
                {
                    proposedCurve = modifiedCurve(originalCurve);
                    //Showing the proposed Curve can cause the window to not draw until dragged when reopening.
                    proposedCurve = EditorGUILayout.CurveField("New Curve: ", proposedCurve, Color.green, new Rect(), GUILayout.Height(windowWidth / 3));
                }
            }
            else
            {
                EditorGUILayout.HelpBox("No Modifiable Curves on this Clip", MessageType.Warning);
            }
            if (valid)
            {
                if (GUILayout.Button("Modify Animation", GUILayout.Height(25)))
                {
                    applyModifications();
                }
            }
            End();
        }