Author Topic: UIslider value gradually changes from one to other  (Read 4681 times)

firoz989

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
UIslider value gradually changes from one to other
« 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

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIslider value gradually changes from one to other
« Reply #1 on: June 25, 2015, 09:07:36 PM »
"foreground sprite suddenly reduces"?

I am not sure what you mean.

firoz989

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: UIslider value gradually changes from one to other
« Reply #2 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

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
Re: UIslider value gradually changes from one to other
« Reply #3 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"