「Unity/GooglePlayGames/ver1」の版間の差分
(→PlayGameのFirebaseユーザ認証) |
|||
| (同じ利用者による、間の2版が非表示) | |||
| 行83: | 行83: | ||
apkを上げてなければ、署名付きのapkをupして、アップロード鍵の証明書が表示されるか確認する | apkを上げてなければ、署名付きのapkをupして、アップロード鍵の証明書が表示されるか確認する | ||
| − | |||
| − | |||
| − | |||
| − | |||
==サンプル実行== | ==サンプル実行== | ||
| 行149: | 行145: | ||
解決方法 | 解決方法 | ||
playconsoleのplaygameのテスター数からメアドを登録すると通る。 | playconsoleのplaygameのテスター数からメアドを登録すると通る。 | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
==PlayConsole公開用アプリでPlayGame認証する場合== | ==PlayConsole公開用アプリでPlayGame認証する場合== | ||
2025年8月4日 (月) 18:15時点における最新版
目次
確認したバージョン
- Firebase:11.8.0
- PlayGame:v.0.10.12
PlayGameプラグインバージョンアップ
0.10.12から0.11.01に上げると以下エラーが出る
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?) 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?) 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'
Unity/GooglePlayGames/v1からv2へ移行 [ショートカット] 側参考
firebaseのバージョンが11.8.0の場合
PlayGameは0.10.12を使わないと、play-sevice周りのライブラリのバージョンが合わなくてエラーが出る。
設定
unityのGamePlayの初期設定
Assets/GooglePlayGames/GameInfo.cs
public const string ApplicationId = ""; // Filled in automatically public const string IosClientId = "__IOS_CLIENTID__"; // Filled in automatically public const string WebClientId = ""; // Filled in automatically public const string NearbyConnectionServiceId = "";
上のClientIdなどをいれる。
Google Play GamesのAndroid Setupの設定
公式:https://firebase.google.com/docs/auth/unity/play-games?hl=ja
- unityのplatformをAndroidにする。
- unityメインメニューから[Window] > [Google Play Games] > [Setup] > [Android Setup] を開き以下を入れる。
Directory to save Constant:Assets/GooglePlayGames Constant class name:GPGSIds Paste in the AndroidResources from the Play Console <?xml version="1.0" encoding="utf-8"?> <!-- Google Play game services IDs. Save this file as res/values/games-ids.xml in your project. --> <resources> <!-- app_id --> <string name="app_id" translatable="false">[ここにAPP_IDを入れる]</string> <!-- package_name --> <string name="package_name" translatable="false">com.example.project1</string> <!-- event Wiped Raid --> <string name="event_wiped_raid" translatable="false">[ここにevent_wiped_raidをいれる]</string> </resources> WebAppClientId:gcp&play画面で入れた、ウェブアプリケーションのClientId
Assets/GooglePlayGames/Plugins/Android/GooglePlayGamesManifest.plugin/AndroidManifest.xml に APP_IDが入ることを確認。
[Window] > [Google Play Games] > [Setup]でAndroidSetupが選択できないとき
- unityのplatformをAndroidにする。
AndroidSetup実行中に"Android SDK Not found"エラーが発生したとき
Android SDK Not found The Android SDK path was not found. Please configure it in the Unity preferences window (under External Tools).
UnityメインメニューのUnity/Settings/ExternalTools/AndroidSDKのrecommendチェックを外して、同じpathを欄に入れると、表示されなくなった。
androidビルドしたときに"Google Play Games not configured!"以下エラー
エラー詳細
Google Play Games not configured! Warning!! Google Play Games was not configured, Game Services will not work correctly.
AndroidSetupがうまくいってないので、↑の項目を確認する。
"Error SignInRequest Sign-in failed with status code: 10"エラーが発生するとき
PlayConsoleのアップロード鍵の証明書が表示されてるか確認する。
apkを上げてなければ、署名付きのapkをupして、アップロード鍵の証明書が表示されるか確認する
サンプル実行
PlayGameログインまで設定
初期設定
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine.SocialPlatforms;
using System.Threading.Tasks;
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
.RequestServerAuthCode(false /* Don't force refresh */)
.Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();
ログインボタンを押したときのログイン成功処理
Social.localUser.Authenticate((bool success) => {
// handle success or failure
});
Authenticate実行で"APP ID IS NOT CORRECTLY CONFIGURED TO USE GOOGLE PLAY GAME SERVICES"エラー
PlayConsoleのテスターにandroidアカウントのメアドを登録するとよい。
fingerprintが一致しないエラー
エラー詳細
**** APP NOT CORRECTLY CONFIGURED TO USE GOOGLE PLAY GAME SERVICES **** DEVELOPER_ERROR **** This is usually caused by one of these reasons: **** (1) Your package name and certificate fingerprint do not match **** the client ID you registered in Developer Console. **** (2) Your App ID was incorrectly entered. **** (3) Your game settings have not been published and you are **** trying to log in with an account that is not listed as **** a test account. **** (4) A server auth code was requested, but an incorrect client **** id was provided. The client id for server auth codes should **** be the client id for the game server (not the android app).
解決方法:playconsoleにアップロード鍵の証明書が登録されているか確認する。なければリリース用apkを追加して、鍵を追加する。
GetServerAuthCode取得
Social.localUser.Authenticate((bool success) => {
if (success) {
string authCode = PlayGamesPlatform.Instance.GetServerAuthCode();
}
});
authCodeは以下のようなフォーマットとなる
4/0AanRRruZXdYF-oq0ER57XxOgo9lBpHoNKAxdVPmYeiXIA9gI4zJpK8OSfAowK88D2JGxxx
successが失敗して、Error16がでる場合
エラー詳細
Error SignInRequest Setting result error status code to: 16
解決方法
playconsoleのplaygameのテスター数からメアドを登録すると通る。
PlayConsole公開用アプリでPlayGame認証する場合
公開前であれば、アップロード鍵の証明書のsha1を以下3つに入れればよかったが、
- FirebaseのプロジェクトAndroidのSHA 証明書フィンガープリント
- Google Cloud Platformで、APIとサービス/認証情報から上部の認証情報を作成を選択、OAuthクライアントを選択→Androidを選択→上のSHA-1証明書のフィンガープリントを貼り付け
- play.google.com/consoleで、ユーザを増やす/PlayGamesサービスのAndroid
PlayConsole経由でDLする場合は、アプリ署名鍵の証明書のsha1を上の3つにいれる必要がある。
