Ejemplo n.º 1
0
    //
    // get high scores from the server
    IEnumerator GetHighScoresCoroutine(GetHighScoresDelegate onGetHighScores)
    {
        using (var request = UnityWebRequest.Get(serverUrl))
        {
            yield return(request.SendWebRequest());

            if (request.error == null)
            {
                // hacky workaround for bad unity json parsing
                var json = "{\"Scores\":" + request.downloadHandler.text + "}";
                print(json);
                ScoreTable scoreTable = JsonUtility.FromJson <ScoreTable>(json);
                onGetHighScores(scoreTable);
            }
            else
            {
                print(request.error);
            }
        }
    }
Ejemplo n.º 2
0
 public void GetHighScores(GetHighScoresDelegate onGetHighScores)
 {
     StartCoroutine(GetHighScoresCoroutine(onGetHighScores));
 }