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("Username",Username);
PlayerPrefs.SetString("Password",Password);
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.
PlayerPrefs.DeleteAll();
}
now the part where i’m saving the data
if(Username=="" && PlayerPrefs.HasKey("Username")){
Username=PlayerPrefs.GetString("Username");
Password=PlayerPrefs.GetString("Password");
}
*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…
edit:
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.
GUI.Label(Rect(20,30,80,20),"Username:");
Username = GUI.TextField(Rect(90,30,100,20),Username);
GUI.Label(Rect(20,60,80,20),"Password:");
Password = GUI.PasswordField(Rect(90,60,100,20),Password,"*"[0],16);
createCookie = GUI.Toggle(Rect(20,80,100,20),createCookie,"Remember Me");
:D just select (highlight) the code and press the "101 010"-button. This will indent every line by 4 spaces and insert empty lines around the code block. This is how UA recognises code. You can also use html tags
– Bunny83<pre></pre>or something like that. UA will automatically convert your 4-indent code block to a<pre>code block after some time. Keep in mind that there's a real-time-preview below your edit field, so you can see how it looks like.I got it that far, it's just that when i select the code and click the code button, it writes "enter code here" in the beginning of the text and ignores the fact that i have selected anything.
– shaystibelman