Xbox Live C#API排行榜示例

时间:2017-03-14 13:23:23

标签: xbox-live

我注册了Xbox Creators计划,我正试图获得排行榜。但是,我找不到任何使用C#API的示例。 This page显示了如何在C ++中完成它。

这是我的代码。它不会构建,因为它说XboxLiveContext doesn't have a LeaderboardService property。如何在C#中创建排行榜服务?

XboxLiveUser user = new XboxLiveUser();

SignInResult x = await user.SignInAsync();

XboxLiveContext context = new XboxLiveContext(user);

LeaderboardResult result = await context.LeaderboardService.GetLeaderboardAsync("scores1", new LeaderboardQuery());

1 个答案:

答案 0 :(得分:2)

对于C#Xbox Creators Program,一些API已被移动。 Leaderboards API现在是StatsManager的一部分。您可以使用StatsManager.Singleton.GetLeaderboard(...)发出请求获取排行榜。

在后台启动请求,当它完成时,将通过调用StatsManager.Singleton.DoWork()返回一个事件。 DoWork方法旨在每帧调用(或者每当您想要从StatsManager通知事件时)。请查看Xbox Live Unity Plugin Leaderboards implementation以获取如何执行此操作的示例。