- Home /
reading user's keyboard input inside a GUI Input field and saving it into variables for later use?
Hey everyone, i'm wondering if there's a way to read user's keyboard input and save it into a variable for later use since i want the user to insert a numeric speed value and watch my dashboard display it.
Thanks
Biohazard
Answer by zmar0519 · Apr 21, 2011 at 03:24 PM
try this:
var inputString : String; private var saveString : String;
function OnGUI() { inputString = GUI.TextArea(Rect(3, 3, Screen.width-6, Screen.height-36), inputString); if(GUI.Button(Rect(3, Screen.height-30, Screen.width/3, 30), "Save the current string")) { saveString = inputString; } if(GUI.Button(Rect(Screen.width/3+3, Screen.height-30, Screen.width/3, 30), "Make the text the saved string")) { inputString = saveString; } if(GUI.Button(Rect(((Screen.width/3)*2)+3, Screen.height-30, Screen.width/3, 30), "Add the saved string to the current string")) { inputString + saveString; } }
Answer by tanronney · Aug 27, 2014 at 07:23 AM
The last one should be :
if(GUI.Button(Rect(((Screen.width/3)*2)+3, Screen.height-30, Screen.width/3, 30), "Add the saved string to the current string")) { inputString= inputString + saveString; } }
Your answer
Follow this Question
Related Questions
Inputing an Equation 0 Answers
Customizing GUI buttons 1 Answer
Keyboard Input Problem 1 Answer
A node in a childnode? 1 Answer
Need help with my script 0 Answers