- Using Unity Toolkit 2D and LeanTween | The Rombos-Blog - [...] It has so much more great features that Unity does not offer (or only for Pro). For tweening, I ...
LeanTween 2.0 does away with passing optional parameters via Hashtables or Arrays, and instead turns to a more robust and cleaner way of passing these parameters with functions. All optional parameters are now passed at the end of the tweening method like so:
LeanTween.moveX( go, 1f, 2f).setEase(LeanTweenType.easeInQuad). setDelay(1f).setOnComplete( someMethod );
You can “daisy-chain” as many optional parameters you want to the end of a method (or none at all).
If you want to go about using the old Hashtable or Array method of passing optional parameters LeanTween will still be backwards compatible.
I ran some tests, to see how much faster the new 2.0 was vs 1.18 using the new performance analyzer with FPS Graph. Below are the results, but to summarize it was about 4% faster. Not too much faster, but every bit counts! Also the new format is much cleaner for passing parameters (you may notice how many lines of code and cruft this helps you avoid).
What I was most impressed with was how the frame-rate drops encountered during my stress-tests were much smaller than the drops in 1.18 (which is a good thing). This is illustrated in the graph below that gives the lowest fps encountered over the 5 stress tests.
Notes on Upgrading
the id of the tween is no longer returned by the tweening method. instead to retrieve this you need to call .id at the end of the method ex:
int uniqueTweenId = LeanTween.scaleZ(gameObject, 1f, 1f).id;
Then you can send this to the cancel/pause/resume methods like before:
LeanTween.pause( uniqueTweenId );