x


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

more ▼

asked Apr 16 '12 at 06:02 PM

hijinxbassist gravatar image

hijinxbassist
2k 23 31 38

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Apr 16 '12 at 06:10 PM

Bunny83 gravatar image

Bunny83
45.4k 11 49 207

@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.

Apr 16 '12 at 06:27 PM hijinxbassist

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.

Apr 16 '12 at 07:20 PM Bunny83

@Bunny83 Awesome, thanks a lot! I am new to GUI Skin, guess its time to dive in. Thanks again for your answer.

Apr 17 '12 at 12:21 AM hijinxbassist
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3695
x507
x103
x62
x4

asked: Apr 16 '12 at 06:02 PM

Seen: 1559 times

Last Updated: Apr 17 '12 at 12:21 AM