Permissions (and priviliges) can be used to validate players are authorized to use features of your game. Some platforms require checking a user’s permissions at the appropriate times before you can release your game to their store. For example, Xbox require you to check a user has the “Online Multiplayer” permission before allowing a player to access online multiplayer in your title
Get a permission from the cache
public static void LogCachedPermission(PlatformPlayer player, Permission permission)
{
PlatformPlayer.PermissionResult result = player.GetCachedPermission(permission);
if(result == PlatformPlayer.PermissionResult.Allowed)
{
Debug.Log(permission.DisplayName + " is allowed!");
}
else
{
Debug.LogWarning(permission.DisplayName + " result: " + result.ToString());
}
}
Get a permission async from the platform
public static void RefreshPermission(PlatformPlayer player, Permission permission)
{
//set
player.GetPermission(permission, true, (result) =>
{
if(result == PlatformPlayer.PermissionResult.Allowed)
{
Debug.Log("Permission refreshed and allowed: " + permission.DisplayName);
}
else
{
Debug.LogWarning("Permission refreshed with result: " + result.ToString());
}
});
}
ex: Permission object that checks ‘Online Multiplayer’
Create a gameobject with component Permissions. Assign all permissions to the List field