Author Topic: UISlider bug?  (Read 10363 times)

cbartlett

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 43
    • View Profile
UISlider bug?
« on: January 15, 2014, 06:09:26 PM »
When I drag the foreground of a slide to an extreme, it doesn't reach the end, dependent on where the foreground is contacted.
On windows player if I create a horizontal slider whose value is displayed
and I use the mouse to touch the extreme far right of the foreground sprite and drag, the display value will never reach 1.  On the other hand if I grab the foreground sprite anywhere left of center and drag the value will reach 1.

What I believe is the bug:
mOffset is set to a of value - ScreenToValue() which in the  case where you are clicking to the right of center will be a negative number.
As you drag value is set based off of the new ScreenToValue + mOffset (which is negative) and since ScreenToValue will never return a value larger than 1, dragging the slider to the right will never result in reaching a value of 1.

Thus the bug: depending on where the foreground is grabbed directly effects whether the slider can reach min/max

POSSIBLE FIX: remove mOffset.  Slider is able to be drug to the min/max
 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISlider bug?
« Reply #1 on: January 15, 2014, 09:16:40 PM »
How would I reproduce this to understand better what you mean?

cbartlett

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 43
    • View Profile
Re: UISlider bug?
« Reply #2 on: January 16, 2014, 10:57:09 AM »
I just created a default slider. (don't know if any of this is specific to the problem but just for exact duplication)
Empty was a sliced sprite 9x16 w/2 pixel borders
Full was a sliced sprite 2x2 with left/right 1 pixel boarder
Thumb was sliced sprite 160x50 with 18 pixel borders

Once added simply run and grab the extreme far right of the thumb and drag.
In the inspector you can see the Value and it won't reach 1.
If you click on the thumb on the left side and drag back to 0, it won't reach it on that side.

Including a pic.

clipboard1 shows the slider and where I am clicking for best reproduction results for moving right(to 1)
clipboard2 shows the same for moving left (to 0)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISlider bug?
« Reply #3 on: January 16, 2014, 10:40:22 PM »
I am not seeing this on my end... what version of NGUI are you using?

cbartlett

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 43
    • View Profile
Re: UISlider bug?
« Reply #4 on: January 16, 2014, 11:48:56 PM »
the current one as of 3 days ago off of the bitbucket site
I just grabbed the latest again and and made a new project and create one and it has the same problem. 

The larger the thumb the more problematic it is.  If you select the thumb on the side you will be dragging it to and drag once it won't make it to the end. It requires several clicks to actually make it to the end.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISlider bug?
« Reply #5 on: January 16, 2014, 11:53:58 PM »
Bitbucket is not used anymore. NGUI is on Github now. There is a note about it in the last commit.

I can't repro it using the "Control - Simple Horizontal Slider" prefab. Even if I change its thumb sprite to be a simple non-anchored sprite, and change it to be "Flag-US", which is quite large.

cbartlett

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 43
    • View Profile
Re: UISlider bug?
« Reply #6 on: January 17, 2014, 12:00:38 AM »
im using the old widget wizard.
If I just add the uislider script and attach it up.
I have a zip of a project if I can give it too you?


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISlider bug?
« Reply #7 on: January 17, 2014, 12:05:45 AM »
The old widget wizard isn't very useful anymore... not since 3.0.6. To be honest I haven't tested anything in it since 3.0.5. I would advise you to try to repro it with the provided controls instead. Chances are you will spot the difference as well.

cbartlett

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 43
    • View Profile
Re: UISlider bug?
« Reply #8 on: January 17, 2014, 12:16:12 AM »
So I loaded the tutorial 7 slider and it has the exact same problem

highlight "Slider - Horizontal" in the hierarchy
with the mouse select the far left of the thumb and drag left, Notice the value it doesn't reach zero.
Now grab the the far right of the thumb and drag right, it won't reach 1.

If you want to reach 0 or 1 you have to drag multiple times.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISlider bug?
« Reply #9 on: January 17, 2014, 12:24:04 AM »
I see what you mean. I'll investigate it tomorrow. Getting a bit late today.

cbartlett

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 43
    • View Profile
Re: UISlider bug?
« Reply #10 on: January 17, 2014, 01:06:42 AM »
NP!  Thanks.  Glad that we were able to communicate and that I was able to finally describe this bug. 

I have also discovered why the code was there.  It prevents popping of the thumb after the user moves the first time.  If the user grabs the side and begins to move the current code keeps it relative to that position.  My way pops just slightly.

Possible Solution:
Hopefully this will help you, the problem boils down to the center of the thumb moves from one extreme to the other of the background.  BUT the ScreenToValue only provides values within the extents of the background.  So anything on either side of the thumb that is outside of the background extents will return min/maxed values. 

Playing around with LocalToValue, i removed the Mathf.clamp01 and I think of all the "hack" I have tried this seems like it actually fixes the issue.
I have tested changing the size of the box collider, the size of the thumb, the collider on the thumb... all seemed to function correctly. 
Basically this allows the ScreenToValue to return negative numbers.  The value seems to clamp itself so in general I think this is the fix that doesn't break anything and fixes the issue.  Especially since progressbar doesn't actually call this and scrollbar overrides it.




ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISlider bug?
« Reply #11 on: January 17, 2014, 11:19:40 PM »
I fixed it earlier this morning btw. You will see the fix in the next update.

cbartlett

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 43
    • View Profile
Re: UISlider bug?
« Reply #12 on: January 18, 2014, 10:21:17 AM »
Thanks!