Author Topic: Changing slider values  (Read 3949 times)

HypoXic5665

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Changing slider values
« on: September 30, 2012, 05:45:28 PM »
Hello, I am trying to make a slider for a power bar with different values than the default. Similar to this post:

http://www.tasharen.com/forum/index.php?topic=425.msg2030#msg2030

It says in there to use this code:

yourValue = Mathf.Lerp(start, end, slider.sliderValue);

Where do I need to put this code and how do I call this value after it has been set/changed.

Thanks for the help,

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Changing slider values
« Reply #1 on: September 30, 2012, 07:42:55 PM »
Wherever you intend to use the slider.sliderValue.

HypoXic5665

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Changing slider values
« Reply #2 on: September 30, 2012, 08:40:07 PM »
Where can I use this? I get a compilation error where ever I try to put it. "Unknown identifier: 'slider'" How do I need to call or define 'slider' in the script to have this work?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Changing slider values
« Reply #3 on: September 30, 2012, 08:45:16 PM »
"slider" is a reference to your UISlider. You get it via GetComponent<UISlider>(), or by having it passed somehow. If you're trying to do it inside the slider callback, you can also use UISlider.current:
  1. float yourValue = Mathf.Lerp(0f, 10f, UISlider.current.sliderValue);

HypoXic5665

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Changing slider values
« Reply #4 on: September 30, 2012, 10:49:45 PM »
Thanks! This works now. Am new to NGUI and am still figuring it all out.