public static IEnumerator GetLeaderboard(DateTime TimeStamp, Action <LeaderboardNodeJS> LeaderboardCallBack)
    {
        //This connects to a server side php script that will add the name and score to a MySQL DB.
        // Supply it with a string representing the players name and the players score.

        string post_url = GetLeaderboardURL + WWW.EscapeURL(GetDateTimeToMySQL(TimeStamp));

        Debug.Log(post_url);
        // Post the URL to the site and create a download object to get the result.
        WWW hs_post = new WWW(post_url);

        yield return(hs_post); // Wait until the download is done

        if (hs_post.error.Length > 0)
        {
            LeaderboardCallBack(null);
            Debug.Log("There was an error adding the names: " + hs_post.error);
        }
        else
        {
            LeaderboardNodeJS LeaderboardNode = JsonUtility.FromJson <LeaderboardNodeJS>(hs_post.text);
            LeaderboardCallBack(LeaderboardNode);
        }

        yield break;
    }
Example #2
0
 void GetLeaderboard(LeaderboardNodeJS Leaderboard)
 {
     if (Leaderboard != null)
     {
         Leaderboard.Print();
     }
     else
     {
         Debug.Log("Leaderboard is null");
     }
 }