Author Topic: Can you set a Slider value with UISlider.current.value  (Read 2191 times)

capitalj

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 88
    • View Profile
Can you set a Slider value with UISlider.current.value
« on: February 17, 2014, 12:32:36 AM »
Hi,
I'm using a UISlider and wanted to know if it was possible to set the value using UISlider.current.value? I tried doing this:
UISlider.current.value = 0.5;

but got a null reference. This is with the slider visible and interacted with.

-JJ

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Can you set a Slider value with UISlider.current.value
« Reply #1 on: February 17, 2014, 04:24:52 AM »
Well, you just could reference the Slider, like this:

  1. UISlider m_slider;
  2.  
  3. void Start()
  4. {
  5. m_slider = GetComponent<UISlider>();
  6.  
  7. m_slider.value = 0.5f;
  8. }

capitalj

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 88
    • View Profile
Re: Can you set a Slider value with UISlider.current.value
« Reply #2 on: February 17, 2014, 01:58:48 PM »
Thanks. I'll probably just do the reference, but was wondering if there was a way to do it without.