I signed up for the Xbox Creators Program, and I'm trying to get a leaderboard. However I couldn't find any examples that use the C# API. This page shows how to do it in C++.
Here is my code. It won't build because it says XboxLiveContext doesn't have a LeaderboardService property
. How do I create a leaderboardservice in C#?
XboxLiveUser user = new XboxLiveUser();
SignInResult x = await user.SignInAsync();
XboxLiveContext context = new XboxLiveContext(user);
LeaderboardResult result = await context.LeaderboardService.GetLeaderboardAsync("scores1", new LeaderboardQuery());
For C# Xbox Creators Program some of the APIs have been moved around. The Leaderboards APIs are now part of the StatsManager
. You can use StatsManager.Singleton.GetLeaderboard(...)
make a request to get a leaderboard.
That starts the request in the background, and when it's complete, an event will be returned by a call to StatsManager.Singleton.DoWork()
. The DoWork
method is intended to be called every frame (or whenever you want to be notified of events from StatsManager). Take a look at the Xbox Live Unity Plugin Leaderboards implementation for an example of how to do this.