「Unity/課金/インストール」の版間の差分
| (同じ利用者による、間の42版が非表示) | |||
| 3行目: | 3行目: | ||
==Unityで課金サービスをONに== | ==Unityで課金サービスをONに== | ||
#unityメニュー/windows/General/Services/ | #unityメニュー/windows/General/Services/InAppPurchasing を選択(2019.2とかだと、Generalは省略されるかもしれない) | ||
# | #PackageManagerが出てきたら、"In App Purchasing"で検索してインストール | ||
v.2022ぐらいまで | |||
#ONにすると、下の方にPurchasingPackageが出てくるので、そこにあるimport(googleやappleなどのプラグイン)ボタンをクリックする | |||
v.6000から | |||
#installして、Configureボタンを押し、上部にでるボタンをONにして、SupportedStoresのGooglePayやAppleAppStoreなどを押す。 | |||
==プレバージョンを使う== | |||
Packages/manifest.json | |||
<pre> | |||
{ | |||
"dependencies": { | |||
"com.unity.purchasing": "5.0.0-pre.7", | |||
} | |||
} | |||
</pre> | |||
公式:https://docs.unity3d.com/Packages/com.unity.purchasing@5.0/manual/StoresSupported.html | |||
もしくは、Edit/ProjectSetting/PackageManagerのShow Pre-releasePackageVersionにチェックを入れて、Unityメインメニュー/Window/PackageManagerで、"In App Purchasing"検索で、Preバージョンを入れる | |||
==Android(Google)を使う場合== | ==Android(Google)を使う場合== | ||
#GooglePublicKeyはGooglePlayDeveloperページの全てのアプリ/該当アプリ/収益化のセットアップ/ | #GooglePublicKeyはGooglePlayDeveloperページの全てのアプリ/該当アプリ/収益化のセットアップ/ライセンスにRSA鍵の392文字の文字列があるのでコピーし、 | ||
#unityメニュー/ | #unity管理画面(https://dashboard.unity3d.com/ )で各アプリ画面に入り、CurrentProject/ProjectSettingにあるIn-app purchaseのGoogleLicenseKeyに、上でコピーした文字列を、貼り付ける。 | ||
#unityメニュー/Services/In-App Purchasing/Configure/Receipt Validation Obfuscator からGooglePublicKeyを設定すると、Assets/Scripts/UnityPurchasing/generated/GooglePlayTangle.csができる。 | |||
===please enter your google public key for this application to ensure revenue numbers reflect verflect verified payments for googleはエラーが出るとき=== | ===please enter your google public key for this application to ensure revenue numbers reflect verflect verified payments for googleはエラーが出るとき=== | ||
| 14行目: | 34行目: | ||
===generated/GooglePlayTangle.csがないとエラーが出る時=== | ===generated/GooglePlayTangle.csがないとエラーが出る時=== | ||
#unityメニュー/ | #unityメニュー/Services/In-App Purchasing/Receipt Validation Obfuscator からGooglePublicKeyを設定する | ||
===Receipt Validation Obfuscatorが見つからないとき=== | |||
unityメニュー/Services/In-App Purchasing/Configure/Receipt Validation Obfuscatorを確認。 | |||
===権限=== | ===権限=== | ||
| 24行目: | 47行目: | ||
NotSupportedException: Failed to bind to native store: UnityEngine.AndroidJavaException: java.lang.ClassNotFoundException: com.unity.purchasing.googleplay.GooglePlayPurchasing | NotSupportedException: Failed to bind to native store: UnityEngine.AndroidJavaException: java.lang.ClassNotFoundException: com.unity.purchasing.googleplay.GooglePlayPurchasing | ||
</pre> | </pre> | ||
unityメニュー/windows/General/Services/ In-App Purchasing からライブラリをONにしてwelcomeのところimportすると以下のファイルが追加される。 | unityメニュー/windows/General/Services/In-App Purchasing からライブラリをONにしてwelcomeのところimportすると以下のファイルが追加される。 | ||
====ver3の場合==== | |||
<pre> | <pre> | ||
Assets/Plugins/UDP/Android/udp.aar | Assets/Plugins/UDP/Android/udp.aar | ||
| 48行目: | 73行目: | ||
Assets/Plugins/UnityPurchasing/ETag | Assets/Plugins/UnityPurchasing/ETag | ||
</pre> | </pre> | ||
====ver4の場合==== | |||
<pre> | |||
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 | |||
</pre> | |||
==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を使う場合== | ||
===iosのアプリサイズ=== | ===iosのアプリサイズ=== | ||
圧縮時のサイズが61.2MB から62.2MB と1MB増えてた。(demo含んでる) | 圧縮時のサイズが61.2MB から62.2MB と1MB増えてた。(demo含んでる) | ||
==IAPのバージョンアップ== | |||
#Windows/PackageManagerを開く | |||
#左上のPackagesをUnityRegistroyへ | |||
#検索から"In App Purchasing"で検索 | |||
#"Update to ~"ボタンを押す | |||
4.4.0から4.8.0に変更の際はIStoreListenerに以下イベントが追加されたので、以下実装を追加した。 | |||
<pre> | |||
public void OnInitializeFailed(InitializationFailureReason error, string message) | |||
{ | |||
Debug.Log("UnityIAPManager OnInitializeFailed " + error.ToString() + " " + message); | |||
} | |||
</pre> | |||
==不要なdir削除== | |||
ver3以降は、以下のdirがある場合は、削除してよい。 | |||
Assets/Plugins/UnityPurchasing | |||
==GooglePlayTangle.Dataで、NotImplementedExceptionエラーが出る場合== | |||
エラー詳細 | |||
<pre> | |||
NotImplementedException: The method or operation is not implemented. | |||
UnityEngine.Purchasing.Security.GooglePlayTangle.Data () (at Assets/Scripts/UnityPurchasing/generated/GooglePlayTangle.cs:15) | |||
</pre> | |||
Android,iOSともに、UnityEditorだとでるっぽい。実機端末側で見ると、問題ないかも。 | |||
==Android実機端末で確認で、ご利用になれません。エラーが出る場合== | |||
エラーメッセージ詳細 | |||
このバージョンのアプリには、google playを通じたお支払いはご利用になれません。 | |||
直接ビルドした場合だと、このメッセージがでるば、Playストアから改めてDLすると、問題なく処理される。 | |||
==2025/8/31までのAndroidGooglePlayBillingLibrary7バージョン対応== | |||
*Android側で、Google Play Billing Library v7に更新すればよい。 | |||
*Unityだと、Unity IAP 4.13.0以上に、更新できればokっぽい。 | |||
https://docs.unity3d.com/Packages/com.unity.purchasing@4.13/changelog/CHANGELOG.html#4130---2025-07-07 | |||
Packages/manifest.json | |||
<pre> | |||
"com.unity.purchasing": "4.13.0", | |||
</pre> | |||
===以下以前の情報=== | |||
*Unityだと、Google Billing Android 7.1.1が含まれる、Unity IAP 5.0.0.-pre6以上に、更新できればokっぽかった。 | |||
https://docs.unity3d.com/Packages/com.unity.purchasing@5.0/manual/StoresSupported.html | |||
unityコミュニティ:https://discussions.unity.com/t/urgent-unity-iap-does-not-support-google-play-billing-library-v7-august-2025-deadline/1661548/27 | |||
5.0.0.-pre7にupしたら、エラーが出た・・・。 | |||
<pre> | |||
UnityIAPManager.cs(217,73): error CS1593: Delegate 'Action<bool, string>' does not take 1 arguments | |||
</pre> | |||
==2024/8/31までのAndroidGooglePlayBillingLibrary6バージョン対応== | |||
*Android側で、Google Play Billing Library v6.0.1に更新すればよい。 | |||
*Unityだと、Unity IAP 4.12.0以上に、更新できればokっぽい。 | |||
=="Unity Gaming Services to have been initialized before use."の警告が出る場合== | |||
警告詳細 | |||
<pre> | |||
Unity IAP: <b>Unity In-App Purchasing</b> requires <b>Unity Gaming Services</b> to have been initialized before use. | |||
- Find out how to initialize <b>Unity Gaming Services</b> by following the documentation <i>https://docs.unity.com/ugs-overview/services-core-api.html#InitializationExample</i> | |||
or download the <i>06 Initialize Gaming Services</i> sample from <i>Package Manager > In-App Purchasing > Samples</i>. | |||
- If you are using the codeless API, you may want to enable the enable <b>Unity Gaming Services</b> automatic initialization by checking the <b>Automatically initialize Unity Gaming Services</b> checkbox at the bottom of the <b>IAP Catalog</b> window | |||
</pre> | |||
公式:https://docs.unity3d.com/Packages/com.unity.purchasing@4.12/manual/UnityIAPInitializeUnityGamingServices.html | |||
<pre> | |||
using System; | |||
using Unity.Services.Core; | |||
using Unity.Services.Core.Environments; | |||
public class InitializeUnityServices | |||
{ | |||
public static string environment = "production"; | |||
public static async void Start() | |||
{ | |||
try | |||
{ | |||
var options = new InitializationOptions() | |||
.SetEnvironmentName(environment); | |||
await UnityServices.InitializeAsync(options); | |||
} | |||
catch (Exception exception) | |||
{ | |||
Debug.LogError("An error occurred during services initialization. message:" + exception.Message); | |||
} | |||
} | |||
} | |||
</pre> | |||
呼び出し | |||
InitializeUnityServices.Start(); | |||
==参考== | ==参考== | ||
https://docs.unity3d.com/ja/current/Manual/UnityIAPSettingUp.html | https://docs.unity3d.com/ja/current/Manual/UnityIAPSettingUp.html | ||
2025年8月28日 (木) 01:34時点における最新版
マニュアル
公式マニュアル:https://docs.unity3d.com/ja/current/Manual/UnityIAP.html
Unityで課金サービスをONに
- unityメニュー/windows/General/Services/InAppPurchasing を選択(2019.2とかだと、Generalは省略されるかもしれない)
- PackageManagerが出てきたら、"In App Purchasing"で検索してインストール
v.2022ぐらいまで
- ONにすると、下の方にPurchasingPackageが出てくるので、そこにあるimport(googleやappleなどのプラグイン)ボタンをクリックする
v.6000から
- installして、Configureボタンを押し、上部にでるボタンをONにして、SupportedStoresのGooglePayやAppleAppStoreなどを押す。
プレバージョンを使う
Packages/manifest.json
{
"dependencies": {
"com.unity.purchasing": "5.0.0-pre.7",
}
}
公式:https://docs.unity3d.com/Packages/com.unity.purchasing@5.0/manual/StoresSupported.html
もしくは、Edit/ProjectSetting/PackageManagerのShow Pre-releasePackageVersionにチェックを入れて、Unityメインメニュー/Window/PackageManagerで、"In App Purchasing"検索で、Preバージョンを入れる
Android(Google)を使う場合
- GooglePublicKeyはGooglePlayDeveloperページの全てのアプリ/該当アプリ/収益化のセットアップ/ライセンスにRSA鍵の392文字の文字列があるのでコピーし、
- unity管理画面(https://dashboard.unity3d.com/ )で各アプリ画面に入り、CurrentProject/ProjectSettingにあるIn-app purchaseのGoogleLicenseKeyに、上でコピーした文字列を、貼り付ける。
- unityメニュー/Services/In-App Purchasing/Configure/Receipt Validation Obfuscator からGooglePublicKeyを設定すると、Assets/Scripts/UnityPurchasing/generated/GooglePlayTangle.csができる。
please enter your google public key for this application to ensure revenue numbers reflect verflect verified payments for googleはエラーが出るとき
- GooglePublicKeyはGooglePlayDeveloperページの全てのアプリ/該当アプリ/収益化/収益化のセットアップ/ライセンスにRSA鍵の392文字の文字列があるので貼り付ける
generated/GooglePlayTangle.csがないとエラーが出る時
- 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のバージョンアップ
- Windows/PackageManagerを開く
- 左上のPackagesをUnityRegistroyへ
- 検索から"In App Purchasing"で検索
- "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すると、問題なく処理される。
2025/8/31までのAndroidGooglePlayBillingLibrary7バージョン対応
- Android側で、Google Play Billing Library v7に更新すればよい。
- Unityだと、Unity IAP 4.13.0以上に、更新できればokっぽい。
Packages/manifest.json
"com.unity.purchasing": "4.13.0",
以下以前の情報
- Unityだと、Google Billing Android 7.1.1が含まれる、Unity IAP 5.0.0.-pre6以上に、更新できればokっぽかった。
https://docs.unity3d.com/Packages/com.unity.purchasing@5.0/manual/StoresSupported.html
5.0.0.-pre7にupしたら、エラーが出た・・・。
UnityIAPManager.cs(217,73): error CS1593: Delegate 'Action<bool, string>' does not take 1 arguments
2024/8/31までのAndroidGooglePlayBillingLibrary6バージョン対応
- Android側で、Google Play Billing Library v6.0.1に更新すればよい。
- Unityだと、Unity IAP 4.12.0以上に、更新できればokっぽい。
"Unity Gaming Services to have been initialized before use."の警告が出る場合
警告詳細
Unity IAP: <b>Unity In-App Purchasing</b> requires <b>Unity Gaming Services</b> to have been initialized before use. - Find out how to initialize <b>Unity Gaming Services</b> by following the documentation <i>https://docs.unity.com/ugs-overview/services-core-api.html#InitializationExample</i> or download the <i>06 Initialize Gaming Services</i> sample from <i>Package Manager > In-App Purchasing > Samples</i>. - If you are using the codeless API, you may want to enable the enable <b>Unity Gaming Services</b> automatic initialization by checking the <b>Automatically initialize Unity Gaming Services</b> checkbox at the bottom of the <b>IAP Catalog</b> window
using System;
using Unity.Services.Core;
using Unity.Services.Core.Environments;
public class InitializeUnityServices
{
public static string environment = "production";
public static async void Start()
{
try
{
var options = new InitializationOptions()
.SetEnvironmentName(environment);
await UnityServices.InitializeAsync(options);
}
catch (Exception exception)
{
Debug.LogError("An error occurred during services initialization. message:" + exception.Message);
}
}
}
呼び出し
InitializeUnityServices.Start();
参考
https://docs.unity3d.com/ja/current/Manual/UnityIAPSettingUp.html