- Home /
Customising a GUI Slider?
Hey guys,
I've read through the entire GUI scripting guide several times and tried looking through the documentation and this site itself, but I cannot find how to change the colour of a simple
GUI.HorizontalSlider(Rect(A,B,C,D),sliderValue,0.0,1.0));
Sure, exposing the GUIStyle var opens op a lot of options, but all of them seem to mainly have to do with buttons. What I simply need is to change the color of the bar and the tab. And preferably also be able to change it through scripting, for instance:
if(sliderValue <= 0.01) {
//change colour to a little more darkish
}
It's most likely something really simple I've overlooked, but god knows I've tried. Many thanks in advance for trying to help! :)
Answer by Jake-L · Mar 25, 2011 at 12:44 PM
Have you tried backgroundColor ?
GUI.backgroundColor=Color.red;
GUI.HorizontalSlider(Rect(A,B,C,D),sliderValue,0.0,1.0));
Thanks! See, it's always something amazingly simple you somehow managed to overlook. Small problem though, I've experimented a bit by having an exposed var backgroundColor:Color; and it seems that the RGB values only affect the Slider Button, not the horizontal bar. The alpha does affect both. It's good enough for me though - but if you do happen to know: how would I change the RGB of the bar?
Your answer
Follow this Question
Related Questions
Access custom style from skin via string 1 Answer
Understanding GUISkin/GUIStyle BackgroundImage and Border 2 Answers
Background of GUI.TextField disappears when using a GUIStyle 2 Answers
Optimizing OnGUI - Too many gui elements? 2 Answers
Changing a GUIStyle for a button from Java Script to C# 2 Answers