how do i tween the value of a variable using itween, i just want to tween it from one value to another in a certain period of time
is it also possible in just one line of code?
how do i tween the value of a variable using itween, i just want to tween it from one value to another in a certain period of time
is it also possible in just one line of code?
No, it’s not possible with one line of code. Tweening a value in iTween.ValueTo() involves using the use of an onupdate callback. Here is an example:
int exampleInt = 0;
iTween.ValueTo( gameObject, iTween.Hash(
"from", exampleInt,
"to", 100,
"time", 1f,
"onupdatetarget", gameObject,
"onupdate", "tweenOnUpdateCallBack",
"easetype", iTween.EaseType.easeOutQuad
)
);
void tweenOnUpdateCallBack( int newValue )
{
exampleInt = newValue;
Debug.Log( exampleInt );
}
As a note, it may be possible in one line with iTween’s native extensions for Unity, which you have to purchase. It allows you to do something like:
gameObject.ValueTo(...);
instead of having to call the Type Reference, such as iTween.ValueTo. It probably still needs an onupdate callback, I would assume.