Demigiant / dotween

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

DOMoveY returns incorrect values #606

Closed igorskugar closed 1 year ago

igorskugar commented 1 year ago

Hi there,

I've purchased DOTween Pro yesterday and I love it.

I'm getting some weird values from DOMoveY(). This piece of code applied to a Canvas, makes its y go from 1.9 to 2.0, instead of expected 2.0 to 2.1.

canvas.transform.DOMoveY(2.1f, 0.5f).From(2f);

Am I doing something wrong here or there is a bug?

Demigiant commented 1 year ago

Ahoy, and glad you like it :)

Via code, UI objects should never be moved via transform.DOMove, but via rectTransform.DOAnchorPos. This is a general rule also when moving them manually, because while you can indeed move a UI transform's position, its coordinates are not the same as its rectTransform's anchoredPosition

Demigiant commented 1 year ago

P.S. I raalized I should clarify: in the DOTweenAnimation component, when you use DOMove but it's attached to a UI's RectTransform, it automatically uses the anchoredPosition in the background

igorskugar commented 1 year ago

Wow, thanks for a detailed response ❤️ Lesson learned, issue fixed :)