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");
//
// }
}
}