Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: nyxojaele on June 27, 2014, 01:10:46 PM

Title: Bug in UIProgressBar: Possible for it to never update under normal circumstances
Post by: nyxojaele on June 27, 2014, 01:10:46 PM
UIProgressBar.set_value() has an optimization in it where it won't perform any update logic if the change between the previous value and the new value is too small. However if every change you ever make is "too small", the progress bar will never update, ever.

Reproduce by taking a default progressbar, and creating a loop that takes about 5000-10000 iterations to linearly interpolate the progressbar's value from 0 to 1. It will never change.

Workaround (I don't believe this should be necessary!):
Call ForceUpdate() manually on the progressbar after changing it's value, which isn't fabulous because it completely obliterates the optimization mentioned above.
Title: Re: Bug in UIProgressBar: Possible for it to never update under normal circumstances
Post by: ArenMook on June 27, 2014, 01:18:41 PM
In what version of NGUI? There was a bug here maybe 5 months ago that has long since been fixed to my knowledge. Right now there is an inequality check, a simple !=.
Title: Re: Bug in UIProgressBar: Possible for it to never update under normal circumstances
Post by: nyxojaele on June 27, 2014, 01:28:25 PM
According to the readme, it's 3.5.3

There is an inequality check, but then later there is something similar to a floating point epsilon check, looking for a minimum change. I'd post the source code where the issue is, but I don't want to post your source without permission.

Basically what I'm seeing in the source code is an inequality check against the current value, and if they're inequal, it basically checks if this.value (note that this does some rounding for the steps, which I'm assuming is why this optimization exists..) has changed by more than 0.001f. If it hasn't, it doesn't update.
Title: Re: Bug in UIProgressBar: Possible for it to never update under normal circumstances
Post by: ArenMook on June 27, 2014, 02:07:59 PM
Yeah you have an old version that still has that bug. Please update, you're many months out of date.