I have a script to control the movement of an elevator. On this script I have a private var that controls the speed - elevSpeed.
I want to be able to control this variable using an Horizontal Slider defined on another script - therapistGUI.
How can I do this?
asked Mar 19 '10 at 09:06 PM
I'll answer my own question because I was able to find the solution. I don't know if you prefer me to delete the question, but I think it can be useful for others.
To access a variable from another script we need to define it as a global variable:
static var elevSpeed
then to access from another script we just need to call the scriptName.globalVarName:
On this case I used the variable to control the speed of the elevator with an horizontal slider:
Elevator.elevSpeed = GUI.HorizontalSlider (Rect(25,185,100,25), Elevator.elevSpeed, 0.0, 10.0);
hope it helps other like me
answered Mar 19 '10 at 09:13 PM