Esempio n. 1
0
    private void DrawAnimatorControl(AnimatorControl control)
    {
        EditorGroup.Horizontal(() => control.ignoreUi = EditorGUILayout.Toggle("ignoreUi", control.ignoreUi));
        EditorGroup.Horizontal(() =>
        {
            control.useInputButton = EditorGUILayout.Toggle("useInputButton", control.useInputButton);
            if (control.useInputButton == false)
            {
                return;
            }
            control.inputButton =
                (PointerEventData.InputButton)EditorGUILayout.Popup((int)control.inputButton, _buttonList);
        });
        EditorGroup.Horizontal(() =>
        {
            EditorGUILayout.LabelField($"Reverse mode", EditorStyles.label, GUILayout.MaxWidth(100));
            var popup = (AnimationModes)EditorGUILayout.Popup((int)control.mode, _modeList);
            if (popup == control.mode)
            {
                return;
            }
            control.mode = popup;
            control.ModeChanged();
        });

        if (GUILayout.Button("UpdateAllParameters"))
        {
            foreach (var systemAnimator in control.animatorSystems)
            {
                systemAnimator.UpdateParameters();
            }
        }
    }
Esempio n. 2
0
    private void DrawAnimatorSystem(AnimatorSystem animSys)
    {
        EditorGroup.Horizontal(() =>
        {
            animSys.animator = (Animator)EditorGUILayout.ObjectField(animSys.animator, typeof(Animator), true);
            if (GUILayout.Button("UpdateParameters", EditorStyles.miniButtonRight))
            {
                animSys.UpdateParameters();
            }
        });

        var parameters = animSys.allAnimatorParameters.ToArray();

        animSys.selectedParameter = EditorGUILayout.Popup("Parameters", animSys.selectedParameter, parameters);

        EditorGroup.Horizontal(() =>
        {
            EditorGUILayout.LabelField("Direction", GUILayout.MinWidth(120), GUILayout.MaxWidth(120));
            var isToBeginning = animSys.Sign == AnimationDirection.ToBeginning;
            if (GUILayout.Toggle(isToBeginning, "<-", EditorStyles.miniButtonLeft))
            {
                animSys.SetSign(AnimationDirection.ToBeginning);
            }
            var isToEnd = animSys.Sign == AnimationDirection.ToEnd;
            if (GUILayout.Toggle(isToEnd, "->", EditorStyles.miniButtonRight))
            {
                animSys.SetSign(AnimationDirection.ToEnd);
            }
        });
        EditorGroup.Vertical(() =>
        {
            animSys.frameRate = EditorGUILayout.FloatField("FrameRate", animSys.frameRate);
            if (animSys.allAnimatorParameters.Count > animSys.selectedParameter)
            {
                var newState = EditorGUILayout.Slider("State", animSys.State, 0, 1);
                if (Math.Abs(newState - animSys.State) > 0)
                {
                    animSys.SetState(newState);
                }
            }

            animSys.playFromStart = EditorGUILayout.Toggle("PlayFromStart", animSys.playFromStart);
        });

        EditorGroup.Horizontal(() =>
        {
            if (GUILayout.Button("Reverse", EditorStyles.miniButtonLeft))
            {
                if (Application.isPlaying)
                {
                    animSys.ReverseAndPlayback();
                }
                else
                {
                    animSys.Reverse();
                    if (animSys.Sign == AnimationDirection.ToEnd)
                    {
                        animSys.SetState(1);
                    }
                    else if (animSys.Sign == AnimationDirection.ToBeginning)
                    {
                        animSys.SetState(0);
                    }
                }
            }

            if (GUILayout.Button(animSys.isPlayback ? "Stop" : "Play current", EditorStyles.miniButtonMid))
            {
                if (animSys.isPlayback)
                {
                    animSys.isPlayback = false;
                }
                else if (Application.isPlaying)
                {
                    if (animSys.Sign == AnimationDirection.ToEnd)
                    {
                        animSys.SetState(0);
                    }
                    else if (animSys.Sign == AnimationDirection.ToBeginning)
                    {
                        animSys.SetState(1);
                    }
                    animSys.Playback();
                }
            }

            if (GUILayout.Button("Reset", EditorStyles.miniButtonRight))
            {
                animSys.Reset();
            }
        });
    }