Author Topic: Problems with UISlider  (Read 6260 times)

Darkness

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 90
    • View Profile
Problems with UISlider
« on: December 05, 2013, 02:26:47 AM »
I upgraded to the newest version of NGUI and now my slider that rotates 360 degrees won't function properly.  In the inspector I can set it up the way I want, but when I run it reverts to settings I never setup.  So has UISlider changed and what to I need to do in order to keep the invert fill and 360 degree radial filling?

JMab

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Problems with UISlider
« Reply #1 on: December 05, 2013, 06:01:04 AM »
I have a different problem with the UISlider. I set my slider.value to 0.5f in code, before it is displayed for the first time. However, the first time I try to drag the thumb when running the game, it jumps to the 1.0f position. Subsequent drags of the thumb, and if I click anywhere on the background on the first or subsequent times, work fine.

In editor mode, I have the thumb positioned at the midpoint and the value set to 0.5f. It makes no difference - for some reason, the UISlider wants the thumb to start at the 1.0f position when dragging it for the first time.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problems with UISlider
« Reply #2 on: December 05, 2013, 03:35:48 PM »
@Darkness: Slider that rotates 360 degrees? I'm not sure what you're trying to make there. Do you mean a radial progress indicator? Sliders now derive from progress bars. If making a radial progress indicator, you don't need the slider script. Just use the sprite set to radial fill mode.

@JMab: You can try calling ForceUpdate(). Looking at the code, I don't see why it shouldn't be called when you change the value, so I'll just make it be called automatically in the next update.

Darkness

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 90
    • View Profile
Re: Problems with UISlider
« Reply #3 on: December 05, 2013, 10:08:06 PM »
@Darkness: Slider that rotates 360 degrees? I'm not sure what you're trying to make there. Do you mean a radial progress indicator? Sliders now derive from progress bars. If making a radial progress indicator, you don't need the slider script. Just use the sprite set to radial fill mode.

Looking at UISlider there is an option to change the fill to radial360.  I did this in the inspector, yet the change won't stay.  When I try to change it via code, I can't find the option to do so.  I tried UISlider.foregroundWidget, but I don't know what to change in code to do it.  I know how to set it up in the inspector as it was working fine before I updated, now it won't work and I can't set the values to get it to work.  Also, fillDirection doesn't list anything to do with radial360. 

My main question is why aren't the values I set in the inspector not saved when I hit play?  And what values do I need to set in order to get that same functionality in code?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problems with UISlider
« Reply #4 on: December 06, 2013, 04:02:45 AM »
UISlider overwrites this option because it has its own setting -- Direction. NGUI's slider doesn't offer a way to do radial sliders (that is widgets you can rotate like knobs). You could do it easily enough by writing some code, but NGUI doesn't do this out of the box.

As I mentioned, don't use the slider. Simply create a sprite and set it to filled mode radial 360, then adjust its fillAmount.

Darkness

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 90
    • View Profile
Re: Problems with UISlider
« Reply #5 on: December 06, 2013, 04:14:03 AM »
UISlider overwrites this option because it has its own setting -- Direction. NGUI's slider doesn't offer a way to do radial sliders (that is widgets you can rotate like knobs). You could do it easily enough by writing some code, but NGUI doesn't do this out of the box.

As I mentioned, don't use the slider. Simply create a sprite and set it to filled mode radial 360, then adjust its fillAmount.

Thanks for the info.  Just curious, why did this change?  Using a sprite for this just seems strange to me.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problems with UISlider
« Reply #6 on: December 06, 2013, 04:16:33 AM »
Slider forces it because that setting on the sprite doesn't support radial mode. It doesn't even have that option.

Filled sprites have a fill amount, which is effectively the same thing as slider.value.

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: Problems with UISlider
« Reply #7 on: February 24, 2014, 01:23:45 PM »
I just notice this.
I think UISlider should support radial sprites.
Doing the script isn't hard, but IMO should support it.

coeing

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 11
    • View Profile
    • slash games
Re: Problems with UISlider
« Reply #8 on: April 04, 2014, 05:03:44 AM »
I just notice this.
I think UISlider should support radial sprites.
Doing the script isn't hard, but IMO should support it.

I agree. Copying the script is possible, but it would be cleaner in my opinion to have an option for the slider direction to just use the sprite settings instead of overwriting them.
Visit slash games at http://www.slashgames.org

Indie Game Developer from Hamburg, Germany.

sonicviz

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 58
    • View Profile
Re: Problems with UISlider
« Reply #9 on: May 25, 2014, 10:05:26 PM »
I've just come across this issue breaking my 360 radial sliders when testing the NGui2.7 to NGui3 upgrade process.

I agree with the others. This is a major pain. Slider should not be overwriting the sprite settings.