- Home /
GUI.TextField problem, won't update var.
Hey geeks! Iv'e got a problem when using GUI.TextField, it won't update the variable. This code worked before i edited. (I added the labels and 1 more textfield) The code:
var showMoreGui = false;
var namevar1 : String = "Namn"; var namevar2 : String = "Namn"; var namevar3 : String = "Namn";
function OnGUI () { if (GUI.Button (Rect (10,10,100,20), "Instllningar")) showMoreGui = true;
if (showMoreGui) {
GUI.Box (Rect (10, 40,500,500), "");
GUI.Label (Rect (20, 50,100,20), "Spelare #1 - ");
namevar1 = GUI.TextField (Rect (90, 50,100,20), ""+namevar1);
PlayerPrefs.SetString("Player1 Name", namevar1);
GUI.Label (Rect (20, 75,100,20), "Spelare #2 - ");
namevar2 = GUI.TextField (Rect (90, 75,100,20), ""+namevar2);
PlayerPrefs.SetString("Player2 Name", namevar2);
GUI.Label (Rect (20, 100,100,20), "Spelare #3 - ");
namevar2 = GUI.TextField (Rect (90, 100,100,20), ""+namevar3);
PlayerPrefs.SetString("Player3 Name", namevar3);
if (GUI.Button (Rect (400, 510,100,20), "Stng"))
showMoreGui = false;
}
}
Am i missing something here?
EDIT: I've solved this problem, realied i used "namevar2" instead of "namevar3" on the last textfield.
Your answer
Follow this Question
Related Questions
[PlayerPrefsSet...] VS [var=...] at every value update 0 Answers
Display Playerpref string in GUI.TextField. 2 Answers
TextField, Event.current, Input.GetKey, and GUI.FocusControl locking 1 Answer
Why is OnGUI not working? 1 Answer
GUI.TextField 1 Answer