Support => NGUI 3 Support => Topic started by: dlewis on October 22, 2012, 11:52:34 PM
Title: TweenPosition with 0 duration broken?
Post by: dlewis on October 22, 2012, 11:52:34 PM
I've just updated from 2.1.6 to 2.3.3 and my tweens are broken. Whenever I attempt to use TweenPosition with a duration of 0 the object gets set to (0, 0, 0).
I started a blank project, downloaded a clean version of NGUI and it still doesn't work. If I have a duration of anything other than 0 it works. I've tried investigating it myself but I haven't had much luck figuring out what's different in the working version vs the broken version.
The only thing odd I have seen is that the OnUpdate function in TweenPosition doesn't seem to work for 0 duration. The problem with the code (below) is that the to and from positions are never set until after the tween has been created so cachedTransform will always be (0, 0, 0) for a tween with 0 duration.
edit: Here is my super simple example script that I'm using in the empty project as reference
Vector3 newPos = go.transform.localPosition;
if(toggle) newPos.y-= 300.0f;
else newPos.y+= 300.0f;
TweenPosition.Begin(go, 0f, newPos);
edit2: I should mention I'm on Unity beta 12. If no one else has this issue I'm pointing the finger straight at Unity.
Title: Re: TweenPosition with 0 duration broken?
Post by: ArenMook on October 23, 2012, 01:38:47 AM
While I question the point of having a tween with duration of 0 (why not just move the object?), you're right at there is an issue here.
I've modified my local version, but if you want to fix it on your end, modify TweenPosition's Begin function, and add this before the return statement: