cherub
1
trying to use a slider to control a var in a script.
i can find a function or a script easy enough, but i am stumped on finding the var in the function that i want to adjust.
for instance, be able to change var speed.
var speed = 1.0;
function Update () {
transform.Translate(Time.deltaTime * speed, 0, 0);
}
how would this be changed to access speed?
var hScrollbarValue : float;
function OnGUI () {
hScrollbarValue = GUI.HorizontalScrollbar (Rect (25, 25, 100, 30), hScrollbarValue, 1.0, 0.0, 10.0);
}
serious thanks
Perhaps I’m not understanding the issue, but it seems like you would just do this:
var speed = 1.0;
function Update () {
transform.Translate(Time.deltaTime * speed, 0, 0);
}
function OnGUI () {
speed = GUI.HorizontalScrollbar (Rect (25, 25, 100, 30), speed, 1.0, 0.0, 10.0);
}
.