- Home /
Change Slider Color and add a custom Slider icon
How do you change the color of the GUI Slider. I am using the horizontal slider. I added a style, but i would like the slider itself to be a different color other than grey.
Also, is it possible to change the little box that you slide back and forth to a different thing? I figure placing a 2D texture plane over the position and referencing the value for screen coordinates. Havent tried it yet, maybe there is a better way of approaching this?
Thanks
Answer by Bunny83 · Apr 16, 2012 at 06:10 PM
You should create your own GUISkin and use it like this in OnGUI:
//C#
public GUISkin mySkin; // assign your skin in the inspector
void OnGUI()
{
GUI.skin = mySkin;
// [...]
}
You can change the default styles of each control. A slider uses multiple styles, just check them out.
@Bunny83 Is the thumb the little box that slides? If i add a texture, does the texture override the box/thumb or does it "Style" the box/thumb using the texture.
Yes the thumb is the slider handle. When you set a different texture it does replace the old one. The whole GUI controls are made of these styles. If you remove all textures from all styles it wouldn't display anything (besides the text). Buttons, windows, whatever, all consists of a GUIStyle. If you're new to the GUIStyle concept it might take a while until you figured out all possibilities, but it's really powerful.
When you create a new GUISkin it get initialized with the (internal) default runtime skin. Just explore the skin to get behind the concept.
Just as a hint: You can edit the GUISkin at runtime so you see realtime results. Quite handy when you want to configure the border(part of the texture that isn't scaled) of a button or window.
@Bunny83 Awesome, thanks a lot! I am new to GUI Skin, guess its time to dive in. Thanks again for your answer.