- Home /
Scrollbar Scroll Scale
is it possible to change the scroll scale so it snaps to whole numbers rather then going into decimals
examples
(#) = posible positions for example
normal scrollbar (scale = 0 - 5 ):
[----(1)-----(2)----]
1 = 2.15479
2 = 4.52154
scrollbar i want (scale 0 - 5):
[----(1)----(2)----]
1 = 2.0
2 = 4.0
You can do anything you want to the scroll value, since you're the one who passes it to the GUI.HorizontalScrollbar function!
Answer by WillTAtl · Dec 08, 2011 at 10:39 PM
you should be able to just round the scroll position it returns before passing back in the next frame, like this...
var barRect:Rect=Rect(0,0,200,16); var scrollPos:float=0;
function OnGUI() { scrollPos=GUI.HorizontalScrollbar(barRect,scrollPos,1,0,5);
//round positions off so they "snap" to integer positions scrollPos=Mathf.Round(scrollPos);
}
:Edit: realized I missed half the point there; easiest way to get the rest would just be to round as I said above and multiply the scrollPos by 2 to get a scaledScrolledPos.
Your answer
Follow this Question
Related Questions
ScrollBar on for loops 0 Answers
How to scroll label view 0 Answers
ScrollRect - Scroll outside the rect!? 0 Answers
4.6 UI ScrollBar force handle size to be fixed 7 Answers
[Question]Scaling Limits 1 Answer