- Home /
Minmax slider on Unity 4.6?
Hello,
I'm currently testing few things on Unity's new UI system and I was surprised that it seems to have no MinMax Slider. So here are my questions:
1) If there is a simple way to create that, I would love to know about it :)
2) If not: Is there is someone that already tried to do it? I was thinking about create a script that inherit from Slider script and modify all behavior but that seems painfull and public member doesn't seems to appear in Editor :/
Does anyone have a solution? :)
Otherwise, I think it will be fine with InputField, thanks!
Answer by HarshadK · Dec 05, 2014 at 08:52 AM
Under Slider there are two variables called Min Value and Max Value that you can set to make it a MinMax Slider with your specified values.
That would be just a slider limited with value :) Here is a $$anonymous$$in$$anonymous$$ax slider to be clearer: http://i.stack.imgur.com/LRVi$$anonymous$$.jpg
$$anonymous$$isunderstood $$anonymous$$in$$anonymous$$ax Slider. Yeah, but a workaround off the top of my head is to have two sliders (one controlling $$anonymous$$ value and another max value) placed overlapping each other. Then user can drag the handles of these to set a value for these sliders. You can then control the value of slider user can drag for each slider via script such that user can not drag his handle from $$anonymous$$ value slider to a value greater than current value from max value slider.
I agree, the duel slider approach seems best for this. If you like you can have a listener that sets the $$anonymous$$ value of the other slider to prevent overlapping.
You can also delete one of the background graphics.
Answer by quansatthu · Dec 06, 2014 at 09:13 AM
Hello,
Code like this:
public class NewGUI : MonoBehaviour {
public float min, max;
//public const float minLimit, maxLimit;
void OnGUI () {
EditorGUILayout.MinMaxSlider (ref min, ref max, minLimit, maxLimit);
//min and max will now store the returning value of the use
}
}
Answer by jmcorallo · Mar 26, 2017 at 05:53 PM
Hi, in case anyone needs a Min-Max slider in Unity 5, here's one I made: https://github.com/jmcorallo/unity-ui-elements
You can download the .unitypackage (version 0.1) directly here: https://github.com/jmcorallo/unity-ui-elements/releases/download/v0.1/UnityUiElements_v0_1.unitypackage
Great $$anonymous$$in-$$anonymous$$ax / two-sided slider. Exactly what I was looking for. Well done!
Your answer
Follow this Question
Related Questions
Horizontal Slider issue 0 Answers
Changing light intensity with a slider 2 Answers
How can i detect changes on a GUI slider? 1 Answer
How to make a Horizontal Slider slide between resolutions? 3 Answers