Why wont player pref save when I press enter on Android?

Hey again, fairly simple problem that’s bugging me…

I have the player name load on the very first screen, in a TextField.
The user can change the name by clicking it.

IN UNITY—
I type in a name, press enter, and it saves my name for next time. Like it is meant to.

ON ANDROID DEVICE—
I tap the name, a keyboard pops up…I type my name, press enter and my keyboard goes away, and my newly typed name appears.

If I reload the app, or change scenes, my name reverts back to “” (nothing).
Why wont it save? It seems logic to me…

Cheers, Tim.

You can see I have it saving the playerpref every time I press the enter key.

I commented out the non important.

EDIT: Just noticed when installing new Unity, another was hiding in task-manager.
maybe that’s the problem, will get back soon.

var playername : String = "Player";

function Awake () {

playername = PlayerPrefs.GetString("playername");

}


function OnGUI(){

    GUI.skin = customskin;
    playername = GUI.TextField (Rect (750, 25, 400, 50), playername, 17);
  
}


function Update () {

    if(Input.GetKeyDown(KeyCode.Return) == true){
      PlayerPrefs.SetString("playername", (playername));
   
   }
//
//    for (var touch : Touch in Input.touches)
//    {
//     if (touch.phase  == TouchPhase.Ended && playButton.HitTest (touch.position)) { 
//        target.animation.Play();
//        LoadAfterDelay("Carselect");            
//     }  
//     
//     if (touch.phase  == TouchPhase.Ended && optionsButton.HitTest (touch.position)) { 
//        target.animation.Play();
//        LoadAfterDelay("Options");            
//     } 
//     
//                     
//     if (touch.phase  == TouchPhase.Ended && online.HitTest (touch.position)) {
//               target.animation.Play();
//               LoadAfterDelay("Server");
//               
//                     } 

       }
}

I accidentally stopped the loop I think.

Took out the { after true and } above for (var touch : Touch in Input.touches)

Heheh oopth.

function Update () {

    if(Input.GetKeyDown(KeyCode.Return) == true)
       PlayerPrefs.SetString("playername", (playername));
   

    for (var touch : Touch in Input.touches)

You don’t get the return button event since on android the keyboard is shown with a native GUI element on top of your unity app. You can see this input field right above the keyboard.

My usual approach on android is to open the [TouchScreenKeyboard][1] manually. I replaced the Textfield with an ordinary button which just opens the keyboard. Once [done][2] is true you can read the

Also try this (using search) How to save text and display using Touch Screen Keyboard - Unity Answers