I am having an issue right now, where I have a TweenAlpha component on a panel that should take it from 0 to 1, and it's duration is set to 0 (i.e. it should be instant). The TweenAlpha starts disabled, so I can enable it at a later time. But when I start the game and enable the Tweener, it fades over the course of about a second or so once it is enabled. After that, if I reset the tween and play it again, it fades in instantly like I would expect.
I looked into the code in UITweener, and I think the problem is related to this:
float mDuration = 0f;
float mAmountPerDelta = 1f; //this gets initialized to 1
float mFactor = 0f;
/// <summary>
/// Amount advanced per delta time.
/// </summary>
public float amountPerDelta
{
get
{
if (mDuration != duration)
{
mDuration = duration;
mAmountPerDelta = Mathf.Abs((duration > 0f) ? 1f / duration : 1000f); //but here it defaults to 1000 if duration is 0 or less
}
return mAmountPerDelta;
}
}
it looks like mAmountPerDelta defaults to 1f when it is initialized, and since mDuration and duration both start at 0, the calculation in there that would normally set it to 1000f never gets called. Shouldn't that initialize to 1000f instead of 1? If I make that change it behaves as I expect, but I'm not sure if it will screw up anything else for me.
I know that tweening alpha from 0 to 1 instantly wouldn't be done in most cases, since you can just activate/deactivate the gameObject to achieve the same effect, but in this case the panel has a few other tweens in different tween groups that need to run on it first, so it's not as simple as that. (It's a highly animated score-tally screen).
Just wondering if this is a bug or not. Thanks!
[Edit:] I should probably mention that I am still on NGUI 2.7, since upgrading to 3 is non-trivial at the moment. So If this is not an issue in 3 then just ignore me
