Ejemplo n.º 1
0
        private void DrawGUI(SlideAnimation anim)
        {
            GUILayout.BeginHorizontal();

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

            GUILayout.BeginVertical();
            anim.Direction = (SlideAnimation.SlideDirection)EditorGUILayout.EnumPopup("Direction", anim.Direction);
            DrawCurveGui(anim);
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }
Ejemplo n.º 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;
                }
            }
        }