I’m using 2017.2.0f3 personal on linux and can’t get urlrequest to work. I’ve tried everything I’ve been able to find searching the internet but can’t get it to work. Is there some really obvious thing that everyone else knows but I don’t?
The script should get a value from a local server but to attempt to eliminate possible errors I put a page on line with just a number on it and change the url to that. (you can check that that works in a browser). However the threaded function never gets past the yield line.
public class follower : MonoBehaviour {
...
public string URL = "https://www.eldwick.org.uk/files/val.txt";
...
void Update () {
if ((Time.time > last_speed_tm + DT) && !url_queried) {
StartCoroutine(WaitForRequest());
}
...
IEnumerator WaitForRequest() {
print("got here");
url_queried = true;
WWW www = new WWW(URL);
print("then here");
yield return www;
print("but never here");
speed = float.Parse(www.text);
print("speed " + speed);
last_speed_tm = Time.time;
url_queried = false;
}
}
I’d be grateful for any pointers.
Paddy
PS amongst the many things I’ve tried was the following commented out version of the coroutine method
/*url_queried = true;
using (UnityWebRequest www = UnityWebRequest.Get (URL)) {
print ("got here");
yield return www.Send ();
print ("but not here");
if (www.isNetworkError || www.isHttpError) {
print ("oops " + www.error);
} else {
speed = float.Parse(www.downloadHandler.text);
print("speed " + speed);
}
}
url_queried = false;
last_speed_tm = Time.time;
}*/