facebook twitter hatena line email

Unity/課金/インストール

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

マニュアル

公式マニュアル:https://docs.unity3d.com/ja/current/Manual/UnityIAP.html

Unityで課金サービスをONに

  1. unityメニュー/windows/General/Services/In-App Purchasing を選択(2019.2とかだと、Generalは省略されるかもしれない)
  2. ONにすると、下の方にPurchasingPackageが出てくるので、そこにあるimport(googleやappleなどのプラグイン)ボタンをクリックする

Android(Google)を使う場合

  1. GooglePublicKeyはGooglePlayDeveloperページの全てのアプリ/該当アプリ/収益化のセットアップ/ライセンスにRSA鍵の392文字の文字列があるのでコピーし、
  2. unity管理画面(https://dashboard.unity3d.com/ )で各アプリ画面に入り、CurrentProject/ProjectSettingにあるIn-app purchaseのGoogleLicenseKeyに、上でコピーした文字列を、貼り付ける。
  3. unityメニュー/Services/In-App Purchasing/Configure/Receipt Validation Obfuscator からGooglePublicKeyを設定すると、generated/GooglePlayTangle.csができる。

please enter your google public key for this application to ensure revenue numbers reflect verflect verified payments for googleはエラーが出るとき

  1. GooglePublicKeyはGooglePlayDeveloperページの全てのアプリ/該当アプリ/収益化/収益化のセットアップ/ライセンスにRSA鍵の392文字の文字列があるので貼り付ける

generated/GooglePlayTangle.csがないとエラーが出る時

  1. unityメニュー/Services/In-App Purchasing/Receipt Validation Obfuscator からGooglePublicKeyを設定する

Receipt Validation Obfuscatorが見つからないとき

unityメニュー/Services/In-App Purchasing/Configure/Receipt Validation Obfuscatorを確認。

権限

com.android.vending.BILLING が追加される

GooglePlayPurchasingが見つからないエラーが出るとき

以下エラーが出るとき

NotSupportedException: Failed to bind to native store: UnityEngine.AndroidJavaException: java.lang.ClassNotFoundException: com.unity.purchasing.googleplay.GooglePlayPurchasing

unityメニュー/windows/General/Services/In-App Purchasing からライブラリをONにしてwelcomeのところimportすると以下のファイルが追加される。

ver3の場合

Assets/Plugins/UDP/Android/udp.aar
Assets/Plugins/UDP/Android/udp.aar.meta
Assets/Plugins/UDP/Android/udpsandbox.aar
Assets/Plugins/UDP/Android/udpsandbox.aar.meta
Assets/Plugins/UDP/Android/utils.aar
Assets/Plugins/UDP/Android/utils.aar.meta
Assets/Plugins/UnityPurchasing/Bin/Android/AmazonAppStore.aar
Assets/Plugins/UnityPurchasing/Bin/Android/AmazonAppStore.aar.meta
Assets/Plugins/UnityPurchasing/Bin/Android/CloudMoolah.aar
Assets/Plugins/UnityPurchasing/Bin/Android/CloudMoolah.aar.meta
Assets/Plugins/UnityPurchasing/Bin/Android/GoogleAIDL.aar
Assets/Plugins/UnityPurchasing/Bin/Android/GoogleAIDL.aar.meta
Assets/Plugins/UnityPurchasing/Bin/Android/GooglePlay.aar
Assets/Plugins/UnityPurchasing/Bin/Android/GooglePlay.aar.meta
Assets/Plugins/UnityPurchasing/Bin/Android/SamsungApps.aar
Assets/Plugins/UnityPurchasing/Bin/Android/SamsungApps.aar.meta
Assets/Plugins/UnityPurchasing/Bin/Android/common.aar
Assets/Plugins/UnityPurchasing/Bin/Android/common.aar.meta
Assets/Plugins/UnityPurchasing/Bin/Editor.dll
Assets/Plugins/UnityPurchasing/Bin/Stores.dll
Assets/Plugins/UnityPurchasing/ETag

ver4の場合

Assets/Resources/IAPProductCatalog.json
Assets/Resources/BillingMode.json
Assets/Scripts/UnityPurchasing/generated/AppleStoreKitTestTangle.cs
Assets/Scripts/UnityPurchasing/generated/AppleTangle.cs
Assets/Scripts/UnityPurchasing/generated/GooglePlayTangle.cs

Legacy Analyticsの警告

警告詳細

warning do not disable the legacy analytics service if you intend to use it for revenue and transaction Tracking. after june 22nd ,2022 , the opt-in rperiod for Legacy Analytics will be closed. After this date, any project that has disabled it will no longer be able to re-enable the Legacy Analytics service

Analyticsを使ってれば、使えなくなってる可能性がある。

iOSを使う場合

iosのアプリサイズ

圧縮時のサイズが61.2MB から62.2MB と1MB増えてた。(demo含んでる)

IAPのバージョンアップ

  1. Windows/PackageManagerを開く
  2. 左上のPackagesをUnityRegistroyへ
  3. 検索から"In App Purchasing"で検索
  4. "Update to ~"ボタンを押す

4.4.0から4.8.0に変更の際はIStoreListenerに以下イベントが追加されたので、以下実装を追加した。

public void OnInitializeFailed(InitializationFailureReason error, string message)
{
    Debug.Log("UnityIAPManager OnInitializeFailed " + error.ToString() + " " + message);
}

不要なdir削除

ver3以降は、以下のdirがある場合は、削除してよい。

Assets/Plugins/UnityPurchasing

GooglePlayTangle.Dataで、NotImplementedExceptionエラーが出る場合

エラー詳細

NotImplementedException: The method or operation is not implemented.
UnityEngine.Purchasing.Security.GooglePlayTangle.Data () (at Assets/Scripts/UnityPurchasing/generated/GooglePlayTangle.cs:15)

Android,iOSともに、UnityEditorだとでるっぽい。実機端末側で見ると、問題ないかも。

Android実機端末で確認で、ご利用になれません。エラーが出る場合

エラーメッセージ詳細

このバージョンのアプリには、google playを通じたお支払いはご利用になれません。

直接ビルドした場合だと、このメッセージがでるば、Playストアから改めてDLすると、問題なく処理される。

参考

https://docs.unity3d.com/ja/current/Manual/UnityIAPSettingUp.html