private void OnLeaderboardScoreUploaded(LeaderboardScoreUploaded_t pCallback, bool bIOFailure) { Debug.Log("[" + LeaderboardScoreUploaded_t.k_iCallback + " - LeaderboardScoreUploaded] - " + pCallback.m_bSuccess + " -- " + pCallback.m_hSteamLeaderboard + " -- " + pCallback.m_nScore + " -- " + pCallback.m_bScoreChanged + " -- " + pCallback.m_nGlobalRankNew + " -- " + pCallback.m_nGlobalRankPrevious); }
internal async Task <LeaderboardScoreUploaded_t?> UploadLeaderboardScore(SteamLeaderboard_t hSteamLeaderboard, LeaderboardUploadScoreMethod eLeaderboardUploadScoreMethod, int nScore, [In, Out] int[] pScoreDetails, int cScoreDetailsCount) { return(await LeaderboardScoreUploaded_t.GetResultAsync(_UploadLeaderboardScore( Self, hSteamLeaderboard, eLeaderboardUploadScoreMethod, nScore, pScoreDetails, cScoreDetailsCount ))); }
private void OnScoreUploaded(LeaderboardScoreUploaded_t pScoreUploadedResult, bool bIOFailure) { Debug.Log("OnScoreUploaded " + pScoreUploadedResult.m_bSuccess + " - " + pScoreUploadedResult.m_bScoreChanged); //if (pScoreUploadedResult.m_bSuccess == 1 && pScoreUploadedResult.m_bScoreChanged == 1) { // //} }
private IEnumerator UpdateLeaderboard(int timeInMilliseconds, string leaderboardName) { Debug.Log("updating leaderboard"); if (!SteamManager.Initialized) { Debug.Log("steammanager not initialized"); yield break; } bool findLeaderboardCallCompleted = false; bool error = false; bool uploadedScoreCallCompleted = false; Steamworks.SteamLeaderboard_t speedrunLeaderboard = new Steamworks.SteamLeaderboard_t(); Steamworks.LeaderboardScoreUploaded_t leaderboardScore = new Steamworks.LeaderboardScoreUploaded_t(); Steamworks.SteamAPICall_t speedrunLeaderboardSearch = Steamworks.SteamUserStats.FindLeaderboard(leaderboardName); Steamworks.CallResult <Steamworks.LeaderboardFindResult_t> findLeaderboardCallResult = Steamworks.CallResult <Steamworks.LeaderboardFindResult_t> .Create(); findLeaderboardCallResult.Set(speedrunLeaderboardSearch, (leaderboardFindResult, failure) => { if (!failure && leaderboardFindResult.m_bLeaderboardFound == 1) { speedrunLeaderboard = leaderboardFindResult.m_hSteamLeaderboard; Debug.Log("speedrunLeaderboard found"); } else { error = true; } findLeaderboardCallCompleted = true; }); while (!findLeaderboardCallCompleted) { yield return(null); } if (error) { Debug.Log("Error finding High Score leaderboard."); yield break; } Steamworks.SteamAPICall_t uploadedScoreCall = Steamworks.SteamUserStats.UploadLeaderboardScore(speedrunLeaderboard, Steamworks.ELeaderboardUploadScoreMethod.k_ELeaderboardUploadScoreMethodKeepBest, timeInMilliseconds, new int[0], 0); Steamworks.CallResult <Steamworks.LeaderboardScoreUploaded_t> leaderboardScoreUploadedCallResult = Steamworks.CallResult <Steamworks.LeaderboardScoreUploaded_t> .Create(); leaderboardScoreUploadedCallResult.Set(uploadedScoreCall, (scoreUploadedResult, failure) => { if (!failure && scoreUploadedResult.m_bSuccess == 1) { leaderboardScore = scoreUploadedResult; Debug.Log("leaderboardScore found"); } else { error = true; } uploadedScoreCallCompleted = true; }); while (!uploadedScoreCallCompleted) { yield return(null); } if (error) { Debug.Log("Error uploading to High Score leaderboard."); yield break; } if (leaderboardScore.m_bScoreChanged == 1) { Debug.Log(String.Format("New high score! Global rank #{0}.", leaderboardScore.m_nGlobalRankNew)); } else { Debug.Log(String.Format("A previous score was better. Global rank #{0}.", leaderboardScore.m_nGlobalRankNew)); } }
internal async Task <LeaderboardScoreUploaded_t?> UploadLeaderboardScore(SteamLeaderboard_t hSteamLeaderboard, LeaderboardUploadScoreMethod eLeaderboardUploadScoreMethod, int nScore, [In][Out] int[] pScoreDetails, int cScoreDetailsCount) { LeaderboardScoreUploaded_t?resultAsync = await LeaderboardScoreUploaded_t.GetResultAsync(this._UploadLeaderboardScore(this.Self, hSteamLeaderboard, eLeaderboardUploadScoreMethod, nScore, pScoreDetails, cScoreDetailsCount)); return(resultAsync); }