- Home /
Question by
furkan ahmet · Apr 29, 2014 at 11:35 PM ·
playerprefshighscore
Write a new high score does not!!!
I could not find flaw. Can you tell me my shortcoming or more?
var point : GUIText;
var level : GUIText;
function Start(){
}
function Awake(){
point.text= "Point: "+ PlayerPrefs.GetInt("HighScore");
level.text= "Level: "+ PlayerPrefs.GetInt("level");
}
function Update () {
if(Input.touchCount == 1) {
var touch = Input.touches[0];
if(touch.phase == TouchPhase.Ended && guiText.HitTest(touch.position)) {
Application.LoadLevel("01");
}
}
}
score table #pragma strict var ses1:AudioClip; static var puan:int=0; var poin : GUIText; function Start () { }
function OnTriggerEnter(nesne:Collider)
{
if(nesne.collider.name=="missile"){
AudioSource.PlayClipAtPoint(ses1, transform.position);
Destroy(this.gameObject);
puan++;
poin.text="Point : "+puan;
}
}
function GameOver() {
if(puan > PlayerPrefs.GetInt("HighScore")){
PlayerPrefs.SetInt("HighScore",puan);
}
}
Comment
Answer by vincentnexon · Apr 30, 2014 at 12:00 AM
If you're wondering why it's not writing to the device, you also need to call PlayerPrefs.Save() although it says it should be automatically saving if you quit the application normally.
Your answer
![](https://koobas.hobune.stream/wayback/20220613143908im_/https://answers.unity.com/themes/thub/images/avi.jpg)