Advertisemen
Copy and paste the code used in the above video :
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class saveLoadDate : MonoBehaviour {
int score;
public Text scoreText;
public InputField username;
// Use this for initialization
void Start () {
scoreText.text = PlayerPrefs.GetString("username")+" : "+PlayerPrefs.GetInt("score");
}
void OnMouseDown(){
score++;
scoreText.text = username.text+" : "+score.ToString();
PlayerPrefs.SetInt("score", score);
PlayerPrefs.SetString("username", username.text);
}
}
using System.Collections;
using UnityEngine.UI;
public class saveLoadDate : MonoBehaviour {
int score;
public Text scoreText;
public InputField username;
// Use this for initialization
void Start () {
scoreText.text = PlayerPrefs.GetString("username")+" : "+PlayerPrefs.GetInt("score");
}
void OnMouseDown(){
score++;
scoreText.text = username.text+" : "+score.ToString();
PlayerPrefs.SetInt("score", score);
PlayerPrefs.SetString("username", username.text);
}
}
Advertisemen
Tidak ada komentar:
Posting Komentar