管理配置文件
Create and manage multiple player profiles on a single device to allow players to sign in with different accounts.
阅读时间1 分钟最后更新于 8 个月前
玩家可以使用配置文件在一台设备上登录多个帐户。配置文件为保存到 中的数值增加了一层隔离。配置文件不会自动持续存在,是否会持续存在取决于开发者的管理方式。
PlayerPrefs切换配置文件
玩家必须注销才能切换当前的配置文件。使用 。配置文件名称仅支持字母数字值、“-”和“_”,且最大字符数为 30。
AuthenticationService.Instance.SwitchProfile(profileName)如果玩家未注销, 会抛出 ,错误代码为 。
SwitchProfileAuthenticationExceptionAuthenticationErrorCodes.ClientInvalidUserState如果使用的是无效名称, 会抛出 ,错误代码为
SwitchProfileAuthenticationExceptionAuthenticationErrorCodes.ClientInvalidProfile当前配置文件
要查看当前配置文件,请使用 。
AuthenticationService.Instance.Profile默认配置文件
如果初始化选项中未提供配置文件,则会使用 值。
default在初始化时设置配置文件
您也可以在初始化 时设置配置文件。如果未提供配置文件, 将使用 值。
UnityServicesAuthenticationServicedefaultasync Task InitializeUnityServices(){ var options = new InitializationOptions(); options.SetProfile(“test_profile”); await UnityServices.InitializeAsync(options);}