- Home /
Customize Slider
Hi to all! :) How can I customize the slider's default unity? with a my image..
I Mean this: http://img821.imageshack.us/img821/720/zae.png
Which part of code I should change? sorry but I'ma beginner.. :/
function OnGUI () {
if(slider >= 1.0)
{
slider = 0;
}
slider= GUI.HorizontalSlider( Rect(20,20,200,30), slider, 0,1.0);
Hour= slider*24;
Tod= slider2*24;
sun.transform.localEulerAngles = Vector3((slider*360)-90, 0, 0);
slider = slider +Time.deltaTime/speed;
sun.color = Color.Lerp (SunNight, SunDay, slider*2);
Answer by TimBorquez · Aug 20, 2013 at 08:51 PM
well one way that i do custom GUI things is i make a gui style variable and then pass it into the gui i want,
so like make a stye variable:
var customStyle : GUIStyle;
and then set up the style in the inspector (onhover and onclick and whatnot) and then pass that style into the slider (the style is usually at the end so it would be something like)
slider= GUI.HorizontalSlider( Rect(20,20,200,30), slider, 0,1.0, customStyle);
and according to this you can pass a style in for both the slider and the little nub i believe
A different way would be to set up a custom skin and then in the ongui function set that skin,
hope that makes sense, and this is just how i do it there may be better ways...
haha only right now cuz im trying to help some people, i answer far too little for how much i ask 0_0
This give me an error..
var customStyle : GUIStyle;
function OnGUI () {
if(slider >= 1.0)
{
slider = 0;
}
slider= GUI.HorizontalSlider( Rect(20,20,200,30), slider, 0,1.0, customStyle);
Hour= slider*24;
Tod= slider2*24;
sun.transform.localEulerAngles = Vector3((slider*360)-90, 0, 0);
slider = slider +Time.deltaTime/speed;
sun.color = Color.Lerp (SunNight, SunDay, slider*2);
Answer by Ejlersen · Aug 20, 2013 at 08:52 PM
If you want to change its style, then you need to create a custom guistyle for it, or modify the existing one.
You can find it in:
GUI.skin.horizontalSlider
GUI.skin.horizontalSliderThumb
Or if you create your own, then you can use:
HorizontalSlider(Rect position, float value, float leftValue, float rightValue, GUIStyle slider, GUIStyle thumb);
Where you can specify your own two guistyles for the horizontal slider.
Your answer
Follow this Question
Related Questions
Horizontal Slider Normal-Background Change Color Independently 3 Answers
Change position - cameras - slider 1 Answer
using rgb to change color c# 1 Answer
Slider doesn't work on Android device 1 Answer
Character Interface Change (Help) 0 Answers