Unity Player Accounts
Use Unity's comprehensive sign-in solution that provides persistent accounts across games, devices, and platforms.
読み終わるまでの所要時間 4 分最終更新 1ヶ月前
概要
Unity Player Accounts は、複数のゲーム、デバイス、プラットフォームをまたいで永続性をサポートする、Unity の包括的なサインインソリューションです。ユーザーフローのユーザー体験、E メールとパスワード、ソーシャルサインインオプション、データのアクセスおよび削除フローを含んだ、エンドツーエンドなアカウントシステムとなっています。 Unity Player Accounts は Unity Gaming Services と統合されており、Anonymous、Apple、Google、Facebook、Steam などと並ぶもう 1 つの ID プロバイダーとして Authentication でサポートされています。シングルサインオン (SSO)、組織レベルのプレイヤープール、また、クロスゲーム、クロスデバイス、クロスプラットフォームのゲームが利用できる利点があります。技術的特徴 | 説明 |
|---|---|
| Unity Gaming Services およびエディターと統合 | Player Accounts は、Unity Gaming Services や Unity のエコシステムに対応したサインインおよび ID ソリューションです。Authentication とシームレスに統合されており、組織レベルのプレイヤー ID など、追加の機能も提供されます。 |
| クロスプラットフォームおよびクロスデバイス | プレイヤーは、iOS、Android、Windows、Mac などのさまざまなプラットフォームでゲームにサインアップおよびサインインできます。 |
| クロスゲーム | 組織レベルのプレイヤー ID を利用し、すべてのゲームにわたって永続的なプレイヤープロファイルを維持できます。 |
| 簡素化されたユーザーサインアップおよびサインイン手順 | プレイヤーは、E メールとパスワード、Google や Apple などのソーシャルアカウントなど、好みに応じた方法でアカウントへのサインアップやサインインを実行できます。 |
| フリクションレスなサインイン体験 | 開始時のアカウントに関する煩わしさを最小限に抑えるために、匿名で開始したプレイヤーが後で Player アカウントにアップグレードしても、進行状況が失われないようにすることができます。また、シングルサインオン (SSO) を使用すれば、一度サインインしたプレイヤーは認証情報を再入力しなくても、Player Accounts 対応のすべてのゲームにアクセスできます。 |
| 1 回の統合で完結 | ブラウザーベースのサインアップとサインインのフローは、ゲームのインテグレーションや更新がなくても、自動的に更新され新機能が反映されます。開発者は、認証ソリューションを再統合する必要なしにゲームの作成や運営に集中できます。一度統合すれば、Player Accounts は常に最新に維持され、最新のセキュリティの改善点と機能が適用されます。 |
使用の準備
SDK のインストール
Unity の最新の Authentication パッケージをインストールするには- Unity エディターで、Window (ウィンドウ) > Package Manager (パッケージマネージャー) を開きます。
- Package Manager で、Unity Registry (Unity レジストリ) のリストビューを選択します。
- Authentication を検索するか、パッケージリスト内で見つけます。
- このパッケージを選択し、Install を選択します。
Unity Player Accounts の設定
Unity Dashboard で直接、Unity Player Accounts を設定できます。 Unity Player Accounts を使用する前に、以下が揃っていることを確認してください。名前 | 説明 |
|---|---|
| 利用規約のリンク | アプリケーションの利用規約。アプリケーションのサインインプロセス (初回サインイン) の同意の手順でリンクを表示します。ノート:このリンクは初期設定では任意ですが、公開する前に利用規約のリンクを指定する必要があります。 |
| プライバシーポリシーのリンク | アプリケーションのプライバシーポリシー。アプリケーションのサインインプロセス (初回サインイン) の同意の手順でリンクを表示します。ノート:このリンクは初期設定では任意ですが、公開する前にプライバシーポリシーのリンクを指定する必要があります。 |
| OAuth クライアント名 | OAuth クライアントの名前。これは同意の手順でユーザーに表示されるため、統合するアプリケーションの名前など、認識できる名前にする必要があります。 |
| プラットフォーム | サポートされるプラットフォーム。Unity Player Accounts は iOS/Android および Windows をサポートしています。 |
ゲームを公開する前に
Unity のコンプライアンスとブランドガイドラインを確認します。- プレイヤーがアプリケーションと Unity Player アカウントのデータ削除要求およびデータ開示要求を行う手段を提供する必要があります。
- Unity Player Accounts のアカウント削除ページ へのリンクを含めます。
- データ開示やその他のプライバシー要求のための Unity Player Accounts のプライバシーサポート E メール へのリンクを含めます。
- データ開示やその他のプライバシー要求のための E メール へのリンクを含めます。
- Unity の利用規約 を常に遵守する必要があります。
- エンドユーザーに対して適切な開示を行い、適用されるすべてのプライバシーとデータ保護に関する法律および規制を遵守し、Unity Player Accounts サービスの使用に必要な権利を Unity に付与する、目立つように配置されたプライバシーポリシーを常に維持、表示、遵守する必要があります。
利用規約とプライバシー
Unity Dashboard に利用規約とプライバシーのリンクが表示されていることを確認します。SDK のインテグレーション
Unity Player Accounts サインインの設定
パッケージをインストールした後、エディターメニューで Services (サービス) > Authentication (認証) > Player Account Settings (プレイヤーアカウント設定) を選択します。
オンボーディング後に取得した以下の値を追加します。
- クライアント ID
- Scope (スコープ) (任意。All または Empty はすべての許可されたスコープを意味します)
- Use Custom Deep Link Uri (カスタムディープリンク URI を使用) (任意。デフォルトのディープリンク URI をオーバーライドします)
Unity Player Accounts のサンプル
- Window (ウィンドウ) > Package Manager (パッケージマネージャー) を選択してサンプルをインポートします。Authentication (認証) を探し、Samples (サンプル) で Import (インポート) を選択します。
- Assets (アセット) > Samples (サンプル) > Authentication (認証) > [パッケージバージョン] > UI Example (UI サンプル) > UnityPlayerAccountsUIExample にあるサンプルシーンを開きます。
Unity Authentication サービスとの統合
Unity Authentication 用に、Unity Player アカウント ID プロバイダーを設定します。- Unity エディターメニューで、Edit > Project Settings... (編集 > プロジェクト設定...) を選択し、ナビゲーションメニューから Services > Authentication (サービス > Authentication) を選択します。
- Go to Dashboard (ダッシュボードに移動) を選択して、Authentication ID プロバイダーのウェブページを開きます。
- ウェブページで Add Identity Provider (ID プロバイダーを追加) を選択し、Unity Player Accounts を選択します。
- プロバイダーを設定し、ポップアップウィンドウで Add provider (プロバイダーを追加) を選択します。
- Unity エディターの Services (サービス) > Authentication (認証) に戻り、Refresh (更新) を選択します。そうすると、Unity Player Accounts ID プロバイダーが表示されます。
- Unity エディターで Services (サービス) > Authentication (認証) > Player Account Settings (プレイヤーアカウント設定) に移動し、クライアント ID が正しく設定されていることを確認します。
- 先ほどインポートしたパッケージサンプルシーン UnityPlayerAccountsUIExample を実行します。
void Awake(){ PlayerAccountService.Instance.SignedIn += SignInWithUnity;}
戻ってきたプレイヤーのサインインまたは新しいプレイヤーの作成
SignInWithUnityAsync- Unity Player Accounts の認証情報を使用して新しい Unity Authentication プレイヤーを作成する。
- Unity Player Accounts の認証情報を使用して既存のプレイヤーをサインインする。
async Task SignInWithUnityAsync(string accessToken){ try { await AuthenticationService.Instance.SignInWithUnityAsync(accessToken); Debug.Log("SignIn is successful."); } catch (AuthenticationException ex) { // Compare error code to AuthenticationErrorCodes // Notify the player with the proper error message Debug.LogException(ex); } catch (RequestFailedException ex) { // Compare error code to CommonErrorCodes // Notify the player with the proper error message Debug.LogException(ex); }}
プレイヤーを匿名から Unity Player アカウントへと更新する
匿名認証を設定した後、プレイヤーが匿名からアップグレードし、Unity Player アカウントを作成してサインインすることを希望する場合は、ゲームのプレイヤーにプロンプトを表示し、Unity Player Accounts サインインをトリガーして Unity Player Accounts からアクセストークンを取得するよう求める必要があります。その後、LinkWithUnityAsync- を使用して、キャッシュされたプレイヤーのアカウントにサインインします。
SignInAnonymouslyAsync - を使用して、キャッシュされたプレイヤーのアカウントを Unity Player アカウントにリンクします。
LinkWithUnityAsync
async Task LinkWithUnityAsync(string accessToken){ try { await AuthenticationService.Instance.LinkWithUnityAsync(accessToken); Debug.Log("Link is successful."); } catch (AuthenticationException ex) when (ex.ErrorCode == AuthenticationErrorCodes.AccountAlreadyLinked) { // Prompt the player with an error message. Debug.LogError("This user is already linked with another account. Log in instead."); } catch (AuthenticationException ex) { // Compare error code to AuthenticationErrorCodes // Notify the player with the proper error message Debug.LogException(ex); } catch (RequestFailedException ex) { // Compare error code to CommonErrorCodes // Notify the player with the proper error message Debug.LogException(ex); }}
Unity Player アカウントのリンク解除
UnlinkUnityAsyncasync Task UnlinkUnityAsync(string idToken){ try { await AuthenticationService.Instance.UnlinkUnityAsync(idToken); Debug.Log("Unlink is successful."); } catch (AuthenticationException ex) { // Compare error code to AuthenticationErrorCodes // Notify the player with the proper error message Debug.LogException(ex); } catch (RequestFailedException ex) { // Compare error code to CommonErrorCodes // Notify the player with the proper error message Debug.LogException(ex); }}