Exemplo n.º 1
0
    public IEnumerator GetBestTimes(int levelID, ReturnDataHTTPDelegate callback)
    {
        UnityWebRequest www = UnityWebRequest.Get(url + "/api/best_time/" + levelID.ToString());

        yield return(www.SendWebRequest());

        if (www.isNetworkError)
        {
            callback(true, false, "");
        }
        else if (www.isHttpError)
        {
            callback(false, false, "");
        }
        else
        {
            // Show results as text
            Debug.Log(www.downloadHandler.text);
            callback(false, true, www.downloadHandler.text);
        }
    }
Exemplo n.º 2
0
    public IEnumerator GetPlayerData(string id, ReturnDataHTTPDelegate callback)
    {
        UnityWebRequest www = UnityWebRequest.Get(url + "/api/player/" + id);


        yield return(www.SendWebRequest());

        if (www.isNetworkError)
        {
            callback(true, false, "");
        }
        else if (www.isHttpError || www.downloadHandler.text == HTTP_REQUEST_EMPTY)
        {
            callback(false, false, "");
        }
        else
        {
            // Show results as text
            Debug.Log(www.downloadHandler.text);
            callback(false, true, www.downloadHandler.text);
        }
    }