Fixed progress bar.

This commit is contained in:
Alex Huddleston 2018-04-26 22:58:14 -05:00
parent 98fbbedcae
commit 3339a851f8
3 changed files with 182 additions and 157 deletions

Binary file not shown.

View file

@ -9,9 +9,10 @@ using System.Text;
//Pretty much a copy of GetData... //Pretty much a copy of GetData...
namespace PedometerU.Tests { 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");
@ -181,6 +206,6 @@ public class GetGoals : MonoBehaviour {
} }
} }
} }
} }
} }