Skip to content

Instantly share code, notes, and snippets.

@Novack
Created April 11, 2016 13:30
Show Gist options
  • Save Novack/07f4c2c587bab94ca11c9977578832a4 to your computer and use it in GitHub Desktop.
Save Novack/07f4c2c587bab94ca11c9977578832a4 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class SynchronousWebCalls : MonoBehaviour
{
string url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=Mar%20del%20Plata&destinations=Balcarce";
void Start()
{
IEnumerator e = Request();
while (e.MoveNext())
if (e.Current != null)
Debug.Log(e.Current as string);
}
IEnumerator Request()
{
WWW www = new WWW(url);
while (!www.isDone)
yield return null;
yield return string.IsNullOrEmpty(www.error) ? www.text : www.error;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment