x


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.

more ▼

asked Mar 22, 2011 at 07:45 PM

Tommy gravatar image

Tommy
171 57 44 50

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5888
x811
x533
x249
x142

asked: Mar 22, 2011 at 07:45 PM

Seen: 1433 times

Last Updated: Mar 22, 2011 at 08:04 PM