- Home /
How do I customize or reshape GUI vertical slider?
I have a vertical slider which acts as throttle control, I have a couple persisting issues with it I've been trying to solve, I tried many things but I couldn't solve them :
Throttle (thumb) starts at half position not all the way down.
2.Slider color is black (or gray) which is sometimes invisible when the scene is a night scene.
with these two major issues i've been thinking about using a texture as a slider, maybe trying to integrate the slider with a more proffesional looking throttle control, but then I will have a problem moving the Texture and/or getting values from it, right now, if i can make it go all the way down and change its' color, that would be good. My current slider setting code:
GUIStyle mySliderStyle = new GUIStyle(GUI.skin.verticalSlider);
GUIStyle myThumbStyle = new GUIStyle(GUI.skin.verticalSlider);
mySliderStyle.fixedWidth = 30;
mySliderStyle.fixedHeight = 100;
mySliderStyle.normal.textColor = Color.red; //this line is useless (it doesn't change slider color because there is no text in slider)
myThumbStyle.fixedWidth = 77;
myThumbStyle.fixedHeight = 10;
vSliderValue = GUI.VerticalSlider(new Rect(20,Screen.height / 2 - 6,100,50), vSliderValue, 10.0F, 0.0F, mySliderStyle,myThumbStyle);
This is what the slider look like now:
As I mentioned, you can see that throttle starts at Half with value of zero and it wouldn't go all the way down, and then all the way to the top is value 10, which is not right (should be zero at bottom, and 10 at top, and 5 at half).
I can not use GUI.backgroundColor
because the slider is not the only element in the OnGUI function, so I don't want to effect other GUI elements, Also when I tried using it, it did not change the slider color anyways, so I thought this is not what I need. I thought of workarounds but non were practical, any ideas, suggestions?
Thank you.