PlayerPrefs clashing with TextField?

Hello all,

I’ve been trying to use PlayerPrefs (only since I weren’t able to get unity to create cookies, dunno why) and I have been able to save and get info from PlayerPrefs.
My problem starts when I try to change the text string I have imported from the PlayerPrefs at Awake()/Start().
For some reason the TextField showing the text string imported, won’t let me modify the field now. No key stroke works.

Any ideas?

Thanks in advance.

following is the code I used:

if(!PlayerPrefs.HasKey("Username") && createCookie){ //check if the user already exists and if he asked to be remembered
    PlayerPrefs.SetString("User",Name+" "+Surname); //saving the full name with which the user logged in
}else if(!createCookie){ //if he doesn't ask to be remembered, i run a "delete all" just to make sure. I have no other place where i use playerprefs so its ok.

now the part where i’m saving the data

if(Username=="" && PlayerPrefs.HasKey("Username")){

*note: i consider myself a fairly intelligent human being and quite the internet savvy, but i STILL don’t understand how the heck this code format thing works…

I’m adding the code for the GUI, as requested by Bunny83, where you can see that I actually DID write it as you suggested.

Username = GUI.TextField(Rect(90,30,100,20),Username);
Password = GUI.PasswordField(Rect(90,60,100,20),Password,"*"[0],16);
createCookie = GUI.Toggle(Rect(20,80,100,20),createCookie,"Remember Me");

Ehmm :D if you have problems with the TextField in Unity, you should post that code. I'm pretty sure you use the TextField like this:


This function returns the edited text, so you have to do it this way:

Username = GUILayout.TextField(Username);


ps. works the same for GUI.TextField.

Stupid question, stupid solution:

Put the variable load part in Start(){} and gui in OnGUI(){} of course.

Happy Kwanza everybody!