snozbot / fungus

An easy to use Unity 3D library for creating illustrated Interactive Fiction games and more.
MIT License
1.63k stars 290 forks source link

LeanTween bug with PNG canvas bigger than the drawing #899

Open breadnone opened 3 years ago

breadnone commented 3 years ago

Describe the bug I'm making custom command which heavily relies on LeanTween and discovered that the tweened objects (in this case, character's sprites) would SOMETIMES stopped offset it's original/default stop position. I said "sometimes" because, it would stop correctly at randoms, more often than not it would stop offset.

See below illustration to better understand what I mean with the problematic PNG leantweenCanvasBug

What's terrible about this bug, is that the offset position would get carried over through the entire scenes.

TIP: If you're trying to reproduce this bug. Pay attention very closely to your computer screen as it happens. I even marked my screen with a marker just to confirm this issue.

To Reproduce Create a PNG as illustrated above. Bigger canvas(this is bitmap canvas. NOT Unity's canvas!) than the drawing itself

Expected behavior It should be back to it's default or intended position correctly

Workaround If "LeanTween.moveY(character.State.portraitImage.rectTransform, 150f, 1f).setLoopPingPong(2)" is used, the way to properly stop it is to set it back with it's zero/default position.

LeanTween.moveY(character.State.portraitImage.rectTransform, 150f, 1f).setEaseInQuad().setLoopPingPong(2).setOnComplete(
                    () =>
                    {
                        LeanTween.moveY(character.State.portraitImage.rectTransform, 0f, 0f);
                        OnTweenComplete();
                    }

Same workarounds with scale and rotate, it should be scaled down to it's default size if LeanTween.scale is used and it should be rotate it back to it's default position if LeanTween.rotate is used.

Using LeanTween.cancel () while checking if the object is still tweening would trigger this bug as well. The above method far from convenient but it works.

This might related to https://github.com/snozbot/fungus/issues/825 Because users at some points were using LeanTween features but did not realize the bug