facebook twitter hatena line email

Unity/GooglePlayGames/v1からv2へ移行

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

v1からv2へ移行

Play Games サービス v2 に移行する(Unity) https://developer.android.com/games/pgs/unity/migrate-to-v2?hl=ja

SignOutエラー対応方法

エラー詳細

error CS1061: 'PlayGamesPlatform' does not contain a definition for 'SignOut' and no accessible extension method 'SignOut' accepting a first argument of type 'PlayGamesPlatform' could be found (are you missing a using directive or an assembly reference?)

対応方法

- ((PlayGamesPlatform)Social.Active).SignOut();
+ Firebase.Auth.FirebaseAuth.DefaultInstance.SignOut();

GetServerAuthCodeエラー対応方法

エラー詳細

error CS1061: 'PlayGamesPlatform' does not contain a definition for 'GetServerAuthCode' and no accessible extension method 'GetServerAuthCode' accepting a first argument of type 'PlayGamesPlatform' could be found (are you missing a using directive or an assembly reference?)

対応前

string authCode = PlayGamesPlatform.Instance.GetServerAuthCode();

対応後

PlayGamesPlatform.Instance.RequestServerSideAccess(
	false,
	authCode =>
	{
		try
		{
			Debug.Log("GooglePlaySignIn: RequestServerSideAccess Success: " + authCode);
		}
		catch (Exception ex)
		{
			Debug.LogError("Error getting credential: " + ex.Message);
		}
	}
);

PlayGamesClientConfigurationエラー対応方法

エラー詳細

error CS0246: The type or namespace name 'PlayGamesClientConfiguration' could not be found (are you missing a using directive or an assembly reference?)

error CS0117: 'PlayGamesPlatform' does not contain a definition for 'InitializeInstance'

https://developer.android.com/games/pgs/unity/migrate-to-v2?hl=ja の対応の通り

対応後

Action<SignInStatus> processAuthentication = (SignInStatus status) =>
{
	if (status == SignInStatus.Success)
	{
            // 成功
	}
	else
	{
            // 失敗
	}
};
// GooglePlay認証開始
PlayGamesPlatform.Instance.Authenticate(processAuthentication);

version2では起動時に自動ログインされる

https://developer.android.com/games/pgs/unity/migrate-to-v2?hl=ja

ゲームが起動すると、自動ログインの試行が表示されます。

https://developer.android.com/games/pgs/unity/migrate-to-v2?hl=ja

Play Games サービス v2 SDK は、ユーザーのログインに関して v1 よりもいくつかの機能が強化されています。

ユーザー向け:
    ユーザー エクスペリエンスの向上: デフォルトのアカウントを選択すると、追加のプロンプトが表示されることなく自動的にログインされます。

デベロッパー向け:
    コード実装の簡素化: クライアントサイド コードでログイン / ログアウトのフローを処理する必要がなくなりました。ゲームの起動時にログインが自動的にトリガーされ、アカウント管理は OS 設定内で効率化されます。