Demigiant / dotween

A Unity C# animation engine. HOTween v2
http://dotween.demigiant.com
Other
2.35k stars 350 forks source link

Overshoot Does Not Work With DOTweenEditorPreview #490

Open nindim opened 3 years ago

nindim commented 3 years ago

Hi,

I have noticed that the overshoot is massively reduced for a tween when running in the editor preview to the point where it looks very different. It doesn't seem to be respecting the value in the DOTween settings.

Please see the attached video showing the Editor Preview versus the PlayMode behaviour for the same Tween (I have increased the overshoot in my project to 17.0158 to make it very obvious).

https://user-images.githubusercontent.com/7597004/119974100-31758e80-bfac-11eb-9a39-589343206297.mp4

using UnityEngine;
using DG.Tweening;

public class DOTweenTest : MonoBehaviour
{
    public RectTransform m_cube = null;

    public Sequence m_sequence;

    // Start is called before the first frame update
    void OnEnable()
    {
        CreateSequence();
    }

    public void CreateSequence()
    {
        if (m_sequence != null)
        {
            m_sequence.Kill();
            m_sequence = null;
        }

        m_sequence = DOTween.Sequence();
        //var tween = m_cube.transform.DOLocalMoveX(4, 2).SetEase(Ease.OutBack).SetDelay(3);
        var tween = m_cube.DOScale(Vector3.zero, 2);
        tween.From();
        tween.SetDelay(0.5f);
        tween.SetEase(Ease.OutBack);
        tween.SetLoops(1);
        m_sequence.Append(tween);
        m_sequence.SetUpdate(isIndependentUpdate: true);
    }
}
using DG.DOTweenEditor;
using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(DOTweenTest))]
public class DoTweenTestEditor : Editor
{
    public override void OnInspectorGUI()
    {
        var tgt = (DOTweenTest) target;

        DrawDefaultInspector();

        if (GUILayout.Button("Play"))
        {
            tgt.CreateSequence();
            DOTweenEditorPreview.PrepareTweenForPreview(tgt.m_sequence);
            DOTweenEditorPreview.Start();
        }

        if (GUILayout.Button("Stop"))
        {
            DOTweenEditorPreview.Stop();
        }
    }
}

Thank you!