void showValueStepper(string label, float min, float max, float step, GET_VALUE getValFunc, SET_VALUE setValFunc) { float curVal = getValFunc(); GUI.color = Color.black; GUILayout.Space(30f); GUILayout.BeginHorizontal(GUILayout.Width(240f)); GUILayout.Label(label, GUILayout.Width(80f)); if (GUILayout.Button("<<", GUILayout.Width(30f))) { curVal -= step; if (curVal < min) { curVal = min; } else { curVal = Mathf.Round(curVal / step) * step; } setValFunc(curVal); } GUILayout.Space(10f); GUILayout.Label(curVal.ToString(), GUILayout.Width(60)); if (GUILayout.Button(">>", GUILayout.Width(30f))) { curVal += step; if (curVal > max) { curVal = max; } else { curVal = Mathf.Round(curVal / step) * step; } setValFunc(curVal); } GUILayout.EndHorizontal(); }
void showValueStepper(string label, float min, float max, float step, GET_VALUE getValFunc, SET_VALUE setValFunc) { float curVal = getValFunc(); GUI.color = Color.black; GUILayout.Space(30f); GUILayout.BeginHorizontal( GUILayout.Width(240f) ); GUILayout.Label(label, GUILayout.Width(80f)); if( GUILayout.Button("<<", GUILayout.Width(30f)) ) { curVal -= step; if( curVal<min ) { curVal = min; } else { curVal = Mathf.Round(curVal/step)*step; } setValFunc(curVal); } GUILayout.Space(10f); GUILayout.Label(curVal.ToString(), GUILayout.Width(60)); if( GUILayout.Button(">>", GUILayout.Width(30f)) ) { curVal += step; if( curVal>max ) { curVal = max; } else { curVal = Mathf.Round(curVal/step)*step; } setValFunc(curVal); } GUILayout.EndHorizontal(); }