listener | Your Application's listener that processes purchasing related events. |
builder | Unity IAP configuration. |
Initialize Unity IAP with the specified listener and configuration.
Here is an example of initializing Unity IAP for a sample Store class.
#pragma strict public class MyStoreClass extends MonoBehaviour { function Start() { var module: var = StandardPurchasingModule.Instance(); var builder: ConfigurationBuilder = ConfigurationBuilder.Instance(module); builder.AddProduct("levelpackfoo", ProductType.NonConsumable); UnityPurchasing.Initialize(this, builder); } public function OnInitialized(controller: IStoreController, extensions: IExtensionProvider) { } public function OnInitializeFailed(error: InitializationFailureReason) { } public function ProcessPurchase(e: PurchaseEventArgs) { return PurchaseProcessingResult.Complete; } public function OnPurchaseFailed(item: Product, r: PurchaseFailureReason) { } }
using UnityEngine; using UnityEngine.Purchasing;
public class MyStoreClass : MonoBehaviour, IStoreListener { void Start() { var module = StandardPurchasingModule.Instance(); ConfigurationBuilder builder = ConfigurationBuilder.Instance(module); builder.AddProduct("levelpackfoo", ProductType.NonConsumable); UnityPurchasing.Initialize(this, builder); } public void OnInitialized(IStoreController controller, IExtensionProvider extensions) {} public void OnInitializeFailed(InitializationFailureReason error) {} public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e) { return PurchaseProcessingResult.Complete; } public void OnPurchaseFailed(Product item, PurchaseFailureReason r) {} }