Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: cbartlett on January 15, 2014, 06:09:26 PM

Title: UISlider bug?
Post by: cbartlett 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
 
Title: Re: UISlider bug?
Post by: ArenMook on January 15, 2014, 09:16:40 PM
How would I reproduce this to understand better what you mean?
Title: Re: UISlider bug?
Post by: cbartlett 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)
Title: Re: UISlider bug?
Post by: ArenMook on January 16, 2014, 10:40:22 PM
I am not seeing this on my end... what version of NGUI are you using?
Title: Re: UISlider bug?
Post by: cbartlett 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.
Title: Re: UISlider bug?
Post by: ArenMook 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.
Title: Re: UISlider bug?
Post by: cbartlett 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?

Title: Re: UISlider bug?
Post by: ArenMook 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.
Title: Re: UISlider bug?
Post by: cbartlett 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.
Title: Re: UISlider bug?
Post by: ArenMook on January 17, 2014, 12:24:04 AM
I see what you mean. I'll investigate it tomorrow. Getting a bit late today.
Title: Re: UISlider bug?
Post by: cbartlett 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.



Title: Re: UISlider bug?
Post by: ArenMook on January 17, 2014, 11:19:40 PM
I fixed it earlier this morning btw. You will see the fix in the next update.
Title: Re: UISlider bug?
Post by: cbartlett on January 18, 2014, 10:21:17 AM
Thanks!