Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Rednaxela on May 29, 2012, 06:06:02 AM

Title: Slider issue
Post by: Rednaxela on May 29, 2012, 06:06:02 AM
Hi,

I'm trying to create slider for options scene in game.
This will be simple horizontal slider with background only and thumb.
I have created slider, but thumb goes beyond left and right borders of the background (see attached).
Is there any way to limit the borders?

Title: Re: Slider issue
Post by: matix on May 29, 2012, 06:45:20 AM
why u dont use the progressBar instead of slider?
Title: Re: Slider issue
Post by: Rednaxela on May 29, 2012, 06:47:36 AM
Because it hasn't thumb.
Title: Re: Slider issue
Post by: ENAY on May 29, 2012, 06:57:11 AM
Why not just scale down the slider bar down and leave the background part at the same length, that way it will fit.
Title: Re: Slider issue
Post by: Rednaxela on May 29, 2012, 07:24:51 AM
It works until I don't change the size of the slider's collider (which actually have to be as size of the background).
If I change size of the collider, I have to change size of the slider itself for proper thumb movement.
And after changing size of the slider, I have almost the same original slider, except stretched background.

By the way, sorry for my bad English.
Title: Re: Slider issue
Post by: ENAY on May 29, 2012, 07:53:26 AM
Perhaps you could cheat in the code and put a check which sets the value when it gets too low or high, if the value is less than 0.1 and more than 0.9 (instead of 0.0 to 1.0) then it sets it at those values.
Title: Re: Slider issue
Post by: ArenMook on May 29, 2012, 01:58:58 PM
Scroll bar would be better for you here, it does what you want. Otherwise -- as others mentioned -- scale the background to make it bigger.
Title: Re: Slider issue
Post by: Rednaxela on May 30, 2012, 02:50:26 AM
OK, I'll try to use scroll bar.
Regarding
Quote
scale the background to make it bigger
, as I said in my previous post, it will work only if I will not change size of the slider's collider.
But in this case thumb will be moving incorrectly (with offset closer to the edges of the slider).
Thanks to all for replies.
Title: Re: Slider issue
Post by: jeldrez on May 22, 2013, 11:54:03 AM
I also have this issue with UISlider and with UIScrollBar it change thumb size in the edges.
Title: Re: Slider issue
Post by: jeldrez on May 23, 2013, 10:38:51 AM
Should exist some thumb offset position option.
Title: Re: Slider issue
Post by: nah0y on May 27, 2013, 04:08:48 AM
+1 for the thumb offset position.

After updating to the new NGUI (version 2.6.1) and you're not using the collider but the sprite size to decide the position of the thumb, everything is broken with my sliders, so I had to revert the script :/

What I've done is change this line :
  1. Vector3 localOffset = mTrans.localPosition - localOrigin;
to this one
  1. Vector3 localOffset = mTrans.localPosition - localOrigin + new Vector3(thumbOffset.x, thumbOffset.y, 0);

And I've modified the UISliderInspector to expose the thumbOffset.
Title: Re: Slider issue
Post by: ArenMook on May 27, 2013, 11:34:36 AM
If you want the thumb to stay inside like that, I would recommend using a scroll bar here instead of a slider bar.
Title: Re: Slider issue
Post by: nah0y on May 27, 2013, 11:37:46 AM
Yes thanks but the scroll bar do not have the progress value :/
Title: Re: Slider issue
Post by: jeldrez on May 28, 2013, 11:16:28 AM
thumb offset pos! ::) :P














please!