예제 #1
0
        private void DrawGUI(ScaleAnimation anim)
        {
            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical();
            GUILayout.Label("Scale", GUILayout.Width(50));
            if (GUILayout.Button("X", GUILayout.Width(20)))
            {
                Remove(anim);
            }
            GUILayout.EndVertical();

            GUILayout.BeginVertical();
            anim.ScaleAxis = (ScaleAnimation.Axis)EditorGUILayout.EnumPopup("Axis", anim.ScaleAxis);
            anim.Scale     = EditorGUILayout.FloatField("Scale", anim.Scale);
            DrawCurveGui(anim);
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }
예제 #2
0
        public void DrawSingleAnimation(SingleAnimation target)
        {
            var title = target.Animations.Count > 0 ? "" : "Empty";

            foreach (BaseAnimation a in target.Animations)
            {
                title += a.GetType().Name + " + ";
            }

            title = title.TrimEnd(' ', '+');

            var style = new GUIStyle(EditorStyles.foldout);

            style.margin = new RectOffset(15, 0, 0, 0);

            if (EditorGUILayout.Foldout(foldout == target, title, true, style))
            {
                foldout            = target;
                target.TimeScale   = EditorGUILayout.FloatField("Time Scale", target.TimeScale);
                target.RepeatCount = EditorGUILayout.IntField("Repeat Count", target.RepeatCount);

                try
                {
                    foreach (BaseAnimation a in target.Animations)
                    {
                        GUILayout.Space(10);
                        switch (a.GetType().Name)
                        {
                        case nameof(SlideAnimation):
                            DrawGUI(a as SlideAnimation);
                            break;

                        case nameof(OffsetAnimation):
                            DrawGUI(a as OffsetAnimation);
                            break;

                        case nameof(ScaleAnimation):
                            DrawGUI(a as ScaleAnimation);
                            break;

                        case nameof(RotateAnimation):
                            DrawGUI(a as RotateAnimation);
                            break;

                        case nameof(FadeAnimation):
                            DrawGUI(a as FadeAnimation);
                            break;
                        }
                    }
                }
                catch
                {
                    //deleted animation
                }

                if (target.Animations.Count > 0)
                {
                    GUILayout.Space(30);
                }
                GUILayout.Label("Add Animation:");

                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Slide"))
                {
                    var a = new SlideAnimation();
                    (target as SingleAnimation).Animations.Add(a);
                    EditorUtility.SetDirty(this.target);
                }

                if (GUILayout.Button("Scale"))
                {
                    var a = new ScaleAnimation();
                    (target as SingleAnimation).Animations.Add(a);
                    EditorUtility.SetDirty(this.target);
                }

                if (GUILayout.Button("Offset"))
                {
                    var a = new OffsetAnimation();
                    (target as SingleAnimation).Animations.Add(a);
                    EditorUtility.SetDirty(this.target);
                }

                if (GUILayout.Button("Rotate"))
                {
                    var a = new RotateAnimation();
                    (target as SingleAnimation).Animations.Add(a);
                    EditorUtility.SetDirty(this.target);
                }

                if (GUILayout.Button("Fade"))
                {
                    var a = new FadeAnimation();
                    (target as SingleAnimation).Animations.Add(a);
                    EditorUtility.SetDirty(this.target);
                }
                GUILayout.EndHorizontal();
            }
            else
            {
                if (foldout == target)
                {
                    foldout = null;
                }
            }
        }