Xbox Live
Tip
For this tutorial, you might find it useful to create a new project to test the process, then apply the knowledge to your existing projects.
Make sure you can run the project from UWP. To do this, in Visual Studio, select the platform you want (UWP-64, UWP-32, or UWP-ARM) from the Solution Platform drop-down list, and run the project.
Download the Xbox Live SDK.
To write this page, we used XboxLiveSDK-1612-20170114-002. The sample is loosely based on the Achievements sample in the Xbox Live SDK.
Change your Xbox Live environment. In the SDK folder, under Tools, run:
XDKS.1 is the sandbox used for the Microsoft samples.
Warning
This blocks regular Xbox accounts and only permits developer accounts. To switch back, run:
- Make sure you can run the Achievements sample with your developer account.
2. Add the Xbox Live SDK to your solution
In Visual Studio, open your game solution.
Open the Package Manager Console (Tools > NuGet Package Manager > Package Manager Console).
Visual Studio adds the NuGet package to your project.
- Make sure the package appears in the References list.
Delete MyGame.UWP.TemporaryKey.pfx.
Add xboxservices.config to your project.
You can get this file from any Xbox Live SDK sample (eg the Achievements sample) for test purposes. When you want to publish the game, change the TitleId and Service config Id with the ones provided for your project. For details, see the Xbox Live documentation.
In the xboxservices.config properties, under Build Action, select Content, and under Copy to Output Directory, select Always.
Edit Package.appxmanifest with details relevant to your project.
Again, you can use the manifest file from any Xbox Live SDK sample (eg the Achievements sample) for test purposes. If you associate your game with a store app, use the generated manifest file. For details, see the Xbox Live documentation.
4. Add user account scripts to your game
You need to enable Xbox Live capability in your game project without exposing the Xbox Live SDK. As MyGame.UWP already references MyGame.Game, we can't reference it. Instead, we can create an interface and implement it from the UWP project side.
Note
There are several ways to do this. This page explains one method.
Add two interfaces to your game, and
IConnectedAccount
.On your UWP project (eg MyGame.UWP), implement the interfaces and
public class XboxLiveAccountManager : IAccountManager
.Add the account factory to your game so you can access it later from a game script. In the , add the following line:
The final script should look like this at minimum:
Now you can expose the xbox_live_user
functionality and other classes in your game.