跳轉至

Unity

本指南提供了在 Hive SDK for Unity 中设置身份验证的说明。

Unity hive 配置編輯器設置

Hive > Hive 配置 (編輯配置) 選擇後,請在Unity Hive 配置編輯器畫面中輸入必要的值,位於執行環境、通用、認證標籤。


安卓


iOS

EDM4U 插件設定

  1. 點擊Hive > Hive 依賴 (ExternalDependency) 菜單。

當設定窗口出現時,請選擇您想要使用的功能。

![](../../img/Hive_Dependencies_Editor_25.0.0.png){width="450px"}

功能新增

僅選擇您想在Hive 模組設定中使用的身份驗證功能。

Note

有關每個功能的詳細指導,請參閱以下內容

添加 IdP

在身份驗證設置中,僅選擇您想要使用的 IdP。例如,要使用 Google IdP,請在身份驗證設置中選擇 Google SignIn。要使用 GooglePlayGames IdP,請選擇 Google Play Games。另一個例子是,如果您想使用 Facebook 登錄,請在身份驗證設置中選擇 Facebook

Note

要在 Unity Android 构建中应用 VK 库,需要 minSdkVersion 为 21 或更高,targetSdkVersion 为 32 或更高。请根据 以下内容 添加 VK 设置。
要在 Unity Android 构建中应用 Line 库,需要 minSdkVersion 为 24 或更高。

Unity 登入模擬器 (可選)

使用 Unity 登入模擬器,您可以在 Hive 沙盒伺服器環境中暫時發出 AuthV4 客戶端帳戶。
Unity 登入模擬器功能可以在 Hive > LoginSimulator > Open AuthV4 Setting 菜單中查看,如下所示。



要使用此功能,您必須滿足以下條件。

  1. hive_config.xml 完整配置
  2. 在 Unity-Build 设置菜单中,在当前平台 (iOS, Android, Windows, Mac) 的 hive_config.xml 中填写 appId (自动填充)
  3. 输入 Hive 认证密钥


    之后,每次按下 创建 按钮时,将会发放一个新的访客帐户,并将帐户信息保存为文件。

您可以通过以下示例代码获取临时访客帐户信息。did和其他附加信息(不包括playerIdplayerToken)是由客户端临时生成或指定的值。

// playerId issued from the Hive Sandbox server
long playerId = AuthV4LoginData.playerId;
// playerToken issued from the Hive Sandbox server
string playerToken = AuthV4LoginData.playerToken;
// playerName set temporarily by the client
string playerName = AuthV4LoginData.playerName;
// playerImageUrl set temporarily by the client
string plalyerImageUrl = AuthV4LoginData.playerImageUrl;
// did set temporarily by the client (random value between 1000000000 and 2000000000)
string did = AuthV4LoginData.did;
Warning

此帳戶為臨時發放的訪客帳戶,方便在 Unity 編輯器畫面上進行測試,特別是針對 Hive 沙盒。必須小心確保它不會與用於商業服務的帳戶信息混合。