Class IAPDemo
An example of Unity IAP functionality. To use with your account, configure the product ids (AddProduct).
Inherited Members
Namespace: Global Namespace
Syntax
[AddComponentMenu("Unity IAP/Demo")]
public class IAPDemo : MonoBehaviour, IStoreListener
Fields
contentRect
The size of the current Product UI content area.
Declaration
public RectTransform contentRect
Field Value
| Type | Description |
|---|---|
| RectTransform |
productUITemplate
The interface for instantiating user interface for a Product.
Instantiates a IAPDemoProductUI.
Declaration
public GameObject productUITemplate
Field Value
| Type | Description |
|---|---|
| GameObject |
restoreButton
The handle for the IAPButton configured to restore IAP transactions.
Declaration
public Button restoreButton
Field Value
| Type | Description |
|---|---|
| Button |
versionText
The reference for the Text to show the current IAP SDK version.
Declaration
public Text versionText
Field Value
| Type | Description |
|---|---|
| Text |
Methods
Awake()
Awake is called when the script instance is being loaded.
Declaration
public void Awake()
OnInitialized(IStoreController, IExtensionProvider)
Purchasing initialized successfully.
The IStoreController and IExtensionProvider are
available for accessing purchasing functionality.
Declaration
public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
Parameters
| Type | Name | Description |
|---|---|---|
| IStoreController | controller | The |
| IExtensionProvider | extensions | The |
Implements
OnInitializeFailed(InitializationFailureReason)
Purchasing failed to initialise for a non recoverable reason.
Declaration
public void OnInitializeFailed(InitializationFailureReason error)
Parameters
| Type | Name | Description |
|---|---|---|
| InitializationFailureReason | error | The failure reason. |
Implements
OnPurchaseFailed(Product, PurchaseFailureReason)
A purchase failed with specified reason.
Declaration
public void OnPurchaseFailed(Product item, PurchaseFailureReason r)
Parameters
| Type | Name | Description |
|---|---|---|
| Product | item | The product that was attempted to be purchased. |
| PurchaseFailureReason | r | The failure reason. |
Implements
ProcessPurchase(PurchaseEventArgs)
A purchase succeeded.
Declaration
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| PurchaseEventArgs | e | The |
Returns
| Type | Description |
|---|---|
| PurchaseProcessingResult | The result of the successful purchase |
Implements
PurchaseButtonClick(String)
Triggered when the user presses the Buy button on a product user interface component.
Declaration
public void PurchaseButtonClick(string productID)
Parameters
| Type | Name | Description |
|---|---|---|
| String | productID | The product identifier to buy |
RestoreButtonClick()
Triggered when the user presses the restore button.
Declaration
public void RestoreButtonClick()