playerpref steps
This commit is contained in:
parent
f857f2f831
commit
ced7137fd0
1 changed files with 8 additions and 3 deletions
|
@ -25,11 +25,11 @@ public class GetGoals : MonoBehaviour {
|
||||||
private Pedometer pedometer;
|
private Pedometer pedometer;
|
||||||
int userSteps;
|
int userSteps;
|
||||||
double userDistance;
|
double userDistance;
|
||||||
int totalSteps = 30;
|
int totalSteps = 100;
|
||||||
public Text stepText;
|
public Text stepText;
|
||||||
|
|
||||||
void OnStep (int steps, double distance) {
|
void OnStep (int steps, double distance) {
|
||||||
userSteps = steps;
|
userSteps = PlayerPrefs.GetInt("lastSteps") + steps;
|
||||||
stepText.text = steps.ToString ();
|
stepText.text = steps.ToString ();
|
||||||
userDistance = (distance * 3.28084);
|
userDistance = (distance * 3.28084);
|
||||||
PlayerPrefs.SetInt("currentSteps",userSteps);
|
PlayerPrefs.SetInt("currentSteps",userSteps);
|
||||||
|
@ -41,12 +41,17 @@ public class GetGoals : MonoBehaviour {
|
||||||
pedometer = null;
|
pedometer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
void Start () {
|
void Start () {
|
||||||
// Create a new pedometer
|
// Create a new pedometer
|
||||||
pedometer = new Pedometer(OnStep(PlayerPrefs.GetInt("currentSteps"), 0));
|
pedometer = new Pedometer(OnStep);
|
||||||
// Reset UI
|
// Reset UI
|
||||||
|
PlayerPrefs.SetInt("lastSteps",PlayerPrefs.GetInt("currentSteps"));
|
||||||
|
|
||||||
OnStep(PlayerPrefs.GetInt("currentSteps"), 0);
|
OnStep(PlayerPrefs.GetInt("currentSteps"), 0);
|
||||||
|
|
||||||
|
|
||||||
//goalText.text = prefKey;
|
//goalText.text = prefKey;
|
||||||
goalText.color = new Color(0f, 0f, 0f);
|
goalText.color = new Color(0f, 0f, 0f);
|
||||||
|
|
||||||
|
|
Reference in a new issue