- Home /
Question by
zooraharrisocks · Aug 19, 2020 at 01:47 AM ·
errorscreenresolution settingstweeningscreensize
DO TWEEN UI Move Tween Float Error on Rescaling Screen Size
I recently started using DO Tween for UI Animations and boy its such a simple tool to use. But I ran into a problem when using the DOMoveY and DOMoveX. When I changed resolution, Since the Move float didn't change, The Tween would overshoot my intended location.
Comment
Let me know if that helped you or whether it's not the system cheapest solution
Best Answer
Answer by zooraharrisocks · Aug 19, 2020 at 02:01 AM
It took me around four hours but I finally fixed
For starters my Canvas reference resolution was 1920×1080. I then made a two floats.
float ratiox = (float) Screen.height / 1920f ;
float ratioy = (float) Screen.width / 1080f ;
Where I would call for the screen size and the devide it by my corresponding axis reference resolution.
Then in the DoTween I would just multiply the ratio with the Distance float and it's all Fixed
UIElementTransform
.DOMoveX (ratiox*tweendistancefloat, tweenduration);