Error Code: FormatException: Input string was not in the correct format.
I got the string from the website and converted it to a float (theres just a single value on the website).
It works in Unity and in Desktop build, but just not on WebGL.
My Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DataLoader : MonoBehaviour {
private int steps;
private string stepsString;
public int whileNumber = 1;
private float kilometers;
private float stepsFloat;
// Use this for initialization
IEnumerator Start () {
while (whileNumber == 1)
{
WWW databaseSteps = new WWW("http://schrittzaehler.rapperswil-jona.ch/globalsteps.php");
yield return databaseSteps;
stepsString = databaseSteps.text;
steps = int.Parse(stepsString);
stepsFloat = steps;
kilometers = stepsFloat * 0.62f / 1000;
PlayerPrefs.SetFloat("kilometersTravelled", kilometers);
Debug.Log(kilometers);
yield return new WaitForSeconds(1);
}
}
// Update is called once per frame
void Update () {
}
}
↧