Toggle slider button

can you make GUI that is toggle slider button? Those are buttons you find on the iphone to set to on/off with button that is a slider.

lesfundi

There isn’t a control that directly does what you’re looking for. However, you can probably create the right effect using a horizontal scrollbar, suitably constrained. If you set the end values to a limited range and make the value variable an integer instead of a float, you will find the slider snaps to the ends of the control:-

var scrollVal: int;

function OnGUI () {
	scrollVal = GUI.HorizontalScrollbar(scrollRect, scrollVal, 1, 0, 2);
}

You can also use the optional GUIStyle parameter to change the look of the control (to have On/Off appear in the background or whatever).

is there any example where i see for reference to make this thing possibel…?