I am using LeanTween as the tween plugin of my Unity Application. But it's frustrating not having a "from-to" type tweening. For an example, I want
//Set initial alpha (from 1f) before animation
var tempColor = forceRing.color;
tempColor.a = 1f;
forceRing.color = tempColor;
//Tween alpha (to 0f)
LeanTween.alpha(forceRing.gameObject, 0f, 0.7f)
to look like this.
//Tween alpha from 1f to 0f;
LeanTween.alpha(forceRing.gameObject, 1f, 0f, 0.7f)
I couldn't find this functionality in LeanTween. What is the best way to achieve this, without writing wrappers or extensions for each tween type on my own?
LeanTween uses the Method chaining pattern to configure tweens.
In your case recommend write the code like this
LeanTween.alpha(forceRing.gameObject,
to: 0f,
time: 0.7f
).setFrom(1.0f);
You can even chain more (optional) configurations (e.g. setting a delay or different ease type) that way:
LeanTween.alpha(forceRing.gameObject,
to: 0f,
time: 0.7f
.setFrom(1.0f).setDelay(0.5f).setEase(LeanTweenType.easeInSine);