Adding multi-user support to a Unity game
The Xbox Live Unity plugin does not support achievements or online multiplayer and is only recommended for members of the Xbox Live Creators Program; see Choosing an Xbox Live developer program.
Multi-user support is supported by the Xbox Live Unity Plugin for scenarios that involve multiple local players. Each player can use their own Xbox Live account for stats and sign-in.
Your game can also enable guests for users that do not have Xbox Live accounts to play. This feature is only supported on Xbox consoles.
This tutorial shows how to add multi-user support to the different Xbox Live Prefabs.
Multi-User Scenarios are only supported on Xbox consoles. This functionality does not work on PC.
First do the steps in Configuring Xbox Live in Unity.
Adding and signing in multiple Xbox Live users
From the Assets > Xbox Live > Prefabs folder, drag onto your scene as many XboxLiveUser prefab instances as there will be players.
For this tutorial, there will be two players so two XboxLiveUser instances will be added to the scene. We'll refer to them as XboxLiveUser and XboxLiveUser2 for convenience.
To properly add the users and sign them in, add two instances of the UserProfile prefab to the scene, one for each XboxLiveUser.
Make sure you have an instance of the
XboxLiveServicesprefab on the scene.
Move the two UserProfile objects apart on the scene, to tell them apart.
Since these prefabs use the Unity Eventsystem, make sure that you have an instance of the
EventSystemon the scene.
Assign one instance of the XboxLiveUser prefabs you have on the scene to each of the UserProfile objects.
Since Multi-User applications are only supported on Xbox One (or later) devices, adding controller support to the UserProfile objects is required. On each UserProfile object, there is a field called
InputControllerButtonwhere you can specify the joystick and button numbers each UserProfile should listen to.
For this tutorial, we'll use
joystick 1 button 0for the UserProfile that Player 1 is assigned to and
joystick 2 button 0for Player 2 and the second UserProfile game object. This will assign the
Abutton for interacting with UserProfile for the two controllers.
For more details about Xbox Controller Support in the Xbox Live Unity Plugin, please check out: Add Controller Support to Xbox Live Prefabs
Run the scene in the editor and hit run on each of the buttons to make sure everything is configured correctly.
Building and Testing the UWP
After following the steps in Configuring Xbox Live in Unity, open the exported UWP solution in Visual Studio.
Under the UWP project of your game, right-click the
package.appxmanifest.xmlfile, and then click View Code.
<Properties></Properties>section, add the following which enables multi-user input for the app:
To test on Xbox, see Set up your UWP on Xbox development environment.
Using the other Xbox Live Prefabs with multiple Users
In the Examples folder of the plugin, there is a MultiUserExample scene that shows how the different prefabs can use the XboxLiveUser instances to display specific information for each user.