Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: firoz989 on June 25, 2015, 07:22:37 AM

Title: UIslider value gradually changes from one to other
Post by: firoz989 on June 25, 2015, 07:22:37 AM
I want to show the remaining time using a UIprogress bar.  I am not able to make foreground sprite gradually reduce. when i change the value of UISlider the foreground sprite suddenly reduces, but i want it to reduce gradually not suddenly from one value to other....

please tell me how can i achive it.

thanks
Title: Re: UIslider value gradually changes from one to other
Post by: ArenMook on June 25, 2015, 09:07:36 PM
"foreground sprite suddenly reduces"?

I am not sure what you mean.
Title: Re: UIslider value gradually changes from one to other
Post by: firoz989 on June 28, 2015, 02:08:43 PM
when a player press a button he will run for a particular time at a faster rate and till that time the progress bar will reduce gradually from say value 1 to 0.75 . 

what i did is sudden change of progressbar from say 1 to 0.75 but this is some thing which I dont want.

I want a code for progressbar which will gradually decrease the progresss bar from a value say 1 to 0.75 in a time "t"...

thanks
Title: Re: UIslider value gradually changes from one to other
Post by: Wisteso on June 28, 2015, 07:57:41 PM
NGUI does not provide the functionality that it sounds like you're seeking. This is something you can easily do yourself. Just maintain two values... "realValue" and "displayValue".

Then you'd do something like displayValue = Lerp(displayValue, realValue, t)

And then its up to you do something like t += Time.deltaTime * scaleFactor; each frame, reset t to zero on value change, etc etc

OR ...

You have "Steps" set to something like "4" instead of being "0"