Author Topic: Slider issue  (Read 9643 times)

Rednaxela

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Slider issue
« 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?

« Last Edit: May 29, 2012, 06:33:43 AM by Rednaxela »

matix

  • Guest
Re: Slider issue
« Reply #1 on: May 29, 2012, 06:45:20 AM »
why u dont use the progressBar instead of slider?

Rednaxela

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Slider issue
« Reply #2 on: May 29, 2012, 06:47:36 AM »
Because it hasn't thumb.

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Slider issue
« Reply #3 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.

Rednaxela

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Slider issue
« Reply #4 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.

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Slider issue
« Reply #5 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Slider issue
« Reply #6 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.

Rednaxela

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Slider issue
« Reply #7 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.

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: Slider issue
« Reply #8 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.

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: Slider issue
« Reply #9 on: May 23, 2013, 10:38:51 AM »
Should exist some thumb offset position option.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: Slider issue
« Reply #10 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.
« Last Edit: May 27, 2013, 04:24:48 AM by nah0y »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Slider issue
« Reply #11 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.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: Slider issue
« Reply #12 on: May 27, 2013, 11:37:46 AM »
Yes thanks but the scroll bar do not have the progress value :/

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: Slider issue
« Reply #13 on: May 28, 2013, 11:16:28 AM »
thumb offset pos! ::) :P














please!