Profile Switching
Profile switching allows you to change which player is considered the "default" user in the SDK. This is useful if your game UI or logic is focused on one player at a time, but you have multiple authenticated users similar to classical console or media streaming profile switching.
Use this for example when the game is played by only one player at a time (locally), but multiple people can share the device. That way, at the beginning of the game session, you ask the player to choose a profile (or sign in a new one). Once that is done, all subsequent requests are made on behalf of that player until the game session ends.
How it Works
The SDK maintains a default user, which is used for API calls if you do not specify a ULID.
You can switch the default user to another authenticated player by their ULID.
This does not log out or remove any users; it only changes which user is considered default (used in calls to LootLocker when no player ULID is specified).
Example: List Previously Logged in Users
In a profile switching scenario, likely you'll want to display a profile selection screen in the beginning of the game session. This is an implementation example of listing data about all previous players stored in the SDK.
var cachedPlayerUlids = LootLockerSDKManager.GetCachedPlayerUlids();
foreach (var playerUlid in cachedPlayerUlids)
{
var playerData = LootLockerSDKManager.GetPlayerDataForPlayerWithUlid(playerUlid);
// Replace with your own method to display player profile
DisplayPlayerProfile(playerData.Name, playerData.ULID, playerData.CurrentPlatform.PlatformFriendlyString, playerData.LastSignIn);
}
Example: Select a profile (set as default)
When the player has selected which player to use for the current session you'll want to set this as the default user in LootLocker.
// Replace with actual player ULID
var selectedPlayerUlid = "selectedPlayerUlid";
if (!LootLockerSDKManager.SetDefaultPlayerUlid(selectedPlayerUlid))
{
Debug.LogError("Failed to set default player ULID.");
}
Last updated