Search Unity

Using PlayerPrefs on Android

Discussion in 'Scripting' started by Ericmatheus, Sep 18, 2014.

  1. Ericmatheus

    Ericmatheus

    Joined:
    Aug 11, 2014
    Posts:
    68
    I did a little code on pc
    #pragma strict
    var nome: String;
    function Start () {
    nome = PlayerPrefs.GetString ("NomeJogador");
    }
    function Update () {
    }
    function OnGUI() {
    nome = GUI.TextArea(Rect(100,100,200,100),nome);
    PlayerPrefs.SetString ("NomeJogador",nome);

    if (nome == PlayerPrefs.GetString ("NomeJogador")!= null)
    PlayerPrefs.Save();
    {
    It's work on pc,but android not let me explain
    The user type on textarea,then what is written is saved,in this case is the user's name
    When load another scene,what the user typed on the textarea appear in a GUI.Label above
    But the problem is on android don't save when we close the application and open again,i want that you write and save,but if exit of the application sttil save what the user wrote
    It's like you type your name and still save when you play again.
    Thanks in advanced