docs.unity3d.com
    Show / Hide Table of Contents

    Class IAPDemo

    An example of Unity IAP functionality. To use with your account, configure the product ids (AddProduct).

    Inheritance
    Object
    IAPDemo
    Namespace: Global Namespace
    Syntax
    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 IStoreController created during initialization.

    IExtensionProvider extensions

    The IExtensionProvider created during initialization.

    Implements
    IStoreListener.OnInitialized(IStoreController, IExtensionProvider)

    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
    IStoreListener.OnInitializeFailed(InitializationFailureReason)

    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
    IStoreListener.OnPurchaseFailed(Product, PurchaseFailureReason)

    ProcessPurchase(PurchaseEventArgs)

    A purchase succeeded.

    Declaration
    public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)
    Parameters
    Type Name Description
    PurchaseEventArgs e

    The PurchaseEventArgs for the purchase event.

    Returns
    Type Description
    PurchaseProcessingResult

    The result of the successful purchase

    Implements
    IStoreListener.ProcessPurchase(PurchaseEventArgs)

    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()
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023