Created
April 11, 2016 13:30
-
-
Save Novack/07f4c2c587bab94ca11c9977578832a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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