Fixed progress bar.
This commit is contained in:
parent
98fbbedcae
commit
3339a851f8
3 changed files with 182 additions and 157 deletions
Binary file not shown.
|
@ -12,6 +12,7 @@ namespace PedometerU.Tests {
|
||||||
public class GetGoals : MonoBehaviour {
|
public class GetGoals : MonoBehaviour {
|
||||||
|
|
||||||
public Image background;
|
public Image background;
|
||||||
|
public Image fill;
|
||||||
private string[] items = { "circle_eye", "crazy_hair", "circle_head", "gap_mouth", "pig_nose", "crown" };
|
private string[] items = { "circle_eye", "crazy_hair", "circle_head", "gap_mouth", "pig_nose", "crown" };
|
||||||
|
|
||||||
public Text goalText;
|
public Text goalText;
|
||||||
|
@ -22,7 +23,7 @@ public class GetGoals : MonoBehaviour {
|
||||||
//Progress Bar...
|
//Progress Bar...
|
||||||
public float barDisplay; //current progress
|
public float barDisplay; //current progress
|
||||||
private Vector2 barPos;
|
private Vector2 barPos;
|
||||||
private Vector2 barSize = new Vector2(725, 39);
|
private Vector2 barSize = new Vector2(5000, 10);
|
||||||
|
|
||||||
//Pedometer
|
//Pedometer
|
||||||
private Pedometer pedometer;
|
private Pedometer pedometer;
|
||||||
|
@ -55,7 +56,11 @@ public class GetGoals : MonoBehaviour {
|
||||||
//saved value from last session loads in on START
|
//saved value from last session loads in on START
|
||||||
//write usersteps + saved val to pref in ONSTEP
|
//write usersteps + saved val to pref in ONSTEP
|
||||||
|
|
||||||
void Start () {
|
void Start ()
|
||||||
|
{
|
||||||
|
fill.type = Image.Type.Filled;
|
||||||
|
fill.fillMethod = Image.FillMethod.Horizontal;
|
||||||
|
fill.type = Image.Type.Sliced;
|
||||||
savedSteps = PlayerPrefs.GetInt("currentSteps");
|
savedSteps = PlayerPrefs.GetInt("currentSteps");
|
||||||
savedPoints = PlayerPrefs.GetInt("totalPoints");
|
savedPoints = PlayerPrefs.GetInt("totalPoints");
|
||||||
// Create a new pedometer
|
// Create a new pedometer
|
||||||
|
@ -82,7 +87,7 @@ public class GetGoals : MonoBehaviour {
|
||||||
goalText.color = new Color(0f, 0f, 0f);
|
goalText.color = new Color(0f, 0f, 0f);
|
||||||
Debug.Log(background.rectTransform.anchoredPosition.x.ToString() + " " + background.rectTransform.anchoredPosition.y.ToString());
|
Debug.Log(background.rectTransform.anchoredPosition.x.ToString() + " " + background.rectTransform.anchoredPosition.y.ToString());
|
||||||
|
|
||||||
barPos = new Vector2(background.transform.position.x, 2135 - background.transform.position.y);
|
barPos = new Vector2(background.transform.position.x, 1895 - background.transform.position.y);
|
||||||
|
|
||||||
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
||||||
goalDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
goalDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
||||||
|
@ -114,8 +119,10 @@ public class GetGoals : MonoBehaviour {
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//
|
/*
|
||||||
void OnGUI() {
|
void OnGUI() {
|
||||||
|
Debug.Log (background.rectTransform.rect.width);
|
||||||
|
barSize = new Vector2 (background.rectTransform.rect.width, background.rectTransform.rect.height);
|
||||||
//draw the background:
|
//draw the background:
|
||||||
GUI.BeginGroup(new Rect(barPos.x, barPos.y, barSize.x, barSize.y));
|
GUI.BeginGroup(new Rect(barPos.x, barPos.y, barSize.x, barSize.y));
|
||||||
GUI.Box(new Rect(0,0, barSize.x, barSize.y), emptyTex);
|
GUI.Box(new Rect(0,0, barSize.x, barSize.y), emptyTex);
|
||||||
|
@ -126,9 +133,27 @@ public class GetGoals : MonoBehaviour {
|
||||||
GUI.EndGroup();
|
GUI.EndGroup();
|
||||||
GUI.EndGroup();
|
GUI.EndGroup();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Was used for testing.
|
||||||
|
private float tempcounter = 0.1f;
|
||||||
|
|
||||||
void Update() {
|
public void updateProgressBar()
|
||||||
|
{
|
||||||
|
barSize.x = background.rectTransform.rect.width;
|
||||||
|
barSize.y = background.rectTransform.rect.height;
|
||||||
|
|
||||||
|
tempcounter += 0.0005f;
|
||||||
|
|
||||||
|
// resize the fill.
|
||||||
|
RectTransform temp = fill.rectTransform;
|
||||||
|
temp.sizeDelta = new Vector2 (barSize.x * tempcounter, barSize.y);
|
||||||
|
temp.anchoredPosition = new Vector2 (temp.rect.width * 0.5f - (barSize.x * 0.5f),0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
updateProgressBar ();
|
||||||
//needs current points counting toward this goal (daily?)
|
//needs current points counting toward this goal (daily?)
|
||||||
//needs the total required points for this goal
|
//needs the total required points for this goal
|
||||||
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
currentDayStr = System.DateTime.Now.ToString("MM/dd/yyyy");
|
||||||
|
|
Binary file not shown.
Reference in a new issue