I have created a php page on my website that displays only a number, for example 3.25 and nothing else. Everything’s running smoothly, i call the url, and in my Debug the number 3.25 displays perfectly. The problem is that I can’t use that number to actually do anything. I need to be able to do something like
if (www.data >= 3.25) {
//do something
}
But in return, I keep getting this error in my console -
error CS0019: Operator >= cannot be applied to operands of type string and double
Thanks for the help in advanced, Heres my code:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Example : MonoBehaviour {
public Text myText;
string url = "http://www.website.com";
void Start () {
WWW www = new WWW(url);
StartCoroutine(WaitForRequest(www));
}
IEnumerator WaitForRequest(WWW www)
{
yield return www;
// check for errors
if (www.error == null)
{
Debug.Log("WWW Ok!: " + www.data);
myText.text = www.data;
if (www.data >= 3.25) {
Debug.Log ("It Worked");
}
} else {
Debug.Log("WWW Error: "+ www.error);
}
}
}