文档

​
​

Development

User Acquisition

Monetization

工业

Authentication

Open Unity Dashboard

Authentication

LiveOps
​
​
Authentication
  • Overview
  • Get started
  • Concepts
    • How Authentication works
    • Approaches to authentication
    • Sessions and cached players
    • Manage profiles
    • Manage player names
    • Manage linked external identities
    • Player prefs
    • Delete accounts
    • Authentication native SDK
    • Digital Services Act Notifications
  • Tutorials
  • Reference
  • Privacy and consent
  1. Unity Authentication

管理配置文件

Create and manage multiple player profiles on a single device to allow players to sign in with different accounts.
阅读时间2 分钟
最后更新于 9 个月前

玩家可以使用配置文件在一台设备上登录多个帐户。配置文件为保存到
PlayerPrefs
中的数值增加了一层隔离。配置文件不会自动持续存在,是否会持续存在取决于开发者的管理方式。

切换配置文件

玩家必须注销才能切换当前的配置文件。使用
AuthenticationService.Instance.SwitchProfile(profileName)
。配置文件名称仅支持字母数字值、“-”和“_”,且最大字符数为 30。
如果玩家未注销,
SwitchProfile
会抛出
AuthenticationException
,错误代码为
AuthenticationErrorCodes.ClientInvalidUserState
。
如果使用的是无效名称,
SwitchProfile
会抛出
AuthenticationException
,错误代码为
AuthenticationErrorCodes.ClientInvalidProfile

当前配置文件

要查看当前配置文件,请使用
AuthenticationService.Instance.Profile
。

默认配置文件

如果初始化选项中未提供配置文件,则会使用
default
值。

在初始化时设置配置文件

您也可以在初始化
UnityServices
时设置配置文件。如果未提供配置文件,
AuthenticationService
将使用
default
值。
async Task InitializeUnityServices(){ var options = new InitializationOptions(); options.SetProfile(“test_profile”); await UnityServices.InitializeAsync(options);}


Copyright © 2026 Unity Technologies
法律信息隐私政策CookiesDocumentation Terms of Use请勿出售或分享我的个人信息您的隐私选择(Cookie 设置)

“Unity”、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属公司在美国和其他地方的商标或注册商标(此处查看更多信息)。其他名称或品牌是其各自所有者的商标。

为方便起见,一些页面是机器翻译的,可能包含不准确的内容。如有信息不一致的情况,以英文版本为准。

  • 在本页上
    • 切换配置文件

    • 当前配置文件

    • 默认配置文件

    • 在初始化时设置配置文件


报告此页面的问题