IEnumerator submitScore() { string newUsername = usernameText.text; if (newUsername.Equals(null) || newUsername.Equals("")) { mainMenuButton.enabled = true; leaderboardButton.enabled = true; submitButton.enabled = true; yield break; } if (!oldUsername.Equals(newUsername)) { yield return(signInAsUsername(newUsername)); } int score = GameObject.FindObjectOfType <ScoreBetweenScenes> ().score; LeaderboardAPI.MatchType mType = GameObject.FindObjectOfType <ScoreBetweenScenes> ().matchType; yield return(api.submitScore(score, mType, () => { Debug.Log("Submitted score successfully to leaderboard."); mainMenuButton.enabled = true; leaderboardButton.enabled = true; }, (error, errorData) => { Debug.LogError("Something went wrong while submitting a score. " + error + ", data: " + errorData.ToString()); mainMenuButton.enabled = true; leaderboardButton.enabled = true; submitButton.enabled = true; })); }
IEnumerator doLogin(LeaderboardAPI api) { bool success = false; yield return(api.logInPlayer("james", "password1", () => { Debug.Log("Success! We logged in as james."); success = true; }, logFailure)); if (!success) { yield break; } yield return(api.submitScore(6000, LeaderboardAPI.MatchType.OneMinuteAR, () => { Debug.Log("Score submitted successfully."); }, logFailure)); yield return(api.getLeaderboard(0, (scores) => { foreach (LeaderboardAPI.LeaderboardScore score in scores) { Debug.Log("Retrieved a new score: " + score.score + " for match type " + score.type.ToString()); } }, logFailure)); }