From ced7137fd0a2000a89a2f56a81a33f20bd990b19 Mon Sep 17 00:00:00 2001 From: asleal2 Date: Thu, 26 Apr 2018 01:36:56 -0500 Subject: [PATCH] playerpref steps --- MoCha/Assets/Scripts/GetGoals.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/MoCha/Assets/Scripts/GetGoals.cs b/MoCha/Assets/Scripts/GetGoals.cs index db59225..ee52978 100644 --- a/MoCha/Assets/Scripts/GetGoals.cs +++ b/MoCha/Assets/Scripts/GetGoals.cs @@ -25,11 +25,11 @@ public class GetGoals : MonoBehaviour { private Pedometer pedometer; int userSteps; double userDistance; - int totalSteps = 30; + int totalSteps = 100; public Text stepText; void OnStep (int steps, double distance) { - userSteps = steps; + userSteps = PlayerPrefs.GetInt("lastSteps") + steps; stepText.text = steps.ToString (); userDistance = (distance * 3.28084); PlayerPrefs.SetInt("currentSteps",userSteps); @@ -41,12 +41,17 @@ public class GetGoals : MonoBehaviour { pedometer = null; } + // + void Start () { // Create a new pedometer - pedometer = new Pedometer(OnStep(PlayerPrefs.GetInt("currentSteps"), 0)); + pedometer = new Pedometer(OnStep); // Reset UI + PlayerPrefs.SetInt("lastSteps",PlayerPrefs.GetInt("currentSteps")); + OnStep(PlayerPrefs.GetInt("currentSteps"), 0); + //goalText.text = prefKey; goalText.color = new Color(0f, 0f, 0f);