Skip to main content

Example Scenes

For a consistent design, it is highly recommended to import your own images and build shop scenes and IAP Item prefabs to match your game's style. This drastically improves conversion rates. Let's go over the demonstrated functionality of the templates included. Each example scene showcases a unique feature of the asset.

01 Buttons

If you do not want to use automatic instantiation, or only have one or two products, you can also drag & drop a product into the scene directly:

  • With a button calling IAPManager.Purchase(productID)
  • Or using a ShopItem prefab and entering the product ID in the inspector, so that the connection to the referenced product in the Project Settings can be established


02 VerticalScroll / 03 HorizontalScroll

These scenes showcase automatic ShopItem instantiation for a category, using the IAPContainer component in a ScrollView. The concept of the IAPContainer has been explained in this section. At the top of these scenes, you can also see a display of the current currency amount, retrieved and set via the CurrencyContainer script.

04 VirtualPurchase

This scene demonstrates purchasing a consumable or non-consumable product in exchange for virtual currency (coins). If you do not have enough coins yet, you can buy some in the previous scenes. Since the consumable product has no reward, it is consumed instantly and therefore not persisted.


05 VirtualPurchaseCount

There is only one product in this scene, granting charges to be consumed later via a rewarded product amount. The current amount purchased is stored locally and displayed next to the product price.

ExampleScenes030 ExampleScenes031

You can consume them later programmatically, by calling IAPManager.Consume(productID, amount).

06 Upgrade

The category for this scene has 4 products, however in the scene you can only see one: that's because we do not make use of automatic instantiation, but placed a prefab in the scene and assigned the base product speed to it in the inspector.

We do it this way because not all products should be visible at the same time, only the currently active upgrade. An alternative is to use different categories, i.e. placing all the upgrade products in a separate category. On each respective product page, the next product is assigned.


If you buy the base product in the game, it is swapped out with the next upgrade, and so forth.


07 SingleSelect

A single-select group can have one product selected at all times. If you purchase and select another product in the same group, the previous one gets deselected. There is no button to deselect a product. And since the first product in the category has no cost defined in the Project Settings, it gets selected automatically as soon as the scene loads.

In addition to the item prefabs not having a deselect button, on the IAPContainer game object there is one additional script responsible for the single-selection behavior: the ToggleGroup component.


08 MultiSelect

In contrast to the single-select group, a multi-select group does not need a ToggleGroup component at all. The instantiated item prefabs just have both a select and deselect button - that's all there is to it.


09 Locked

This scene features two locked products, which have to be unlocked by reaching a specific criteria. The criteria is the level value, which needs to be 1 or 2 respectively. For testing purposes, there is a button in the scene that let's you increase the level value.


The concept of Requirements has been explained in this section.

10 Bundle

A bundled product allows you to grant multiple other products with only one purchase, e.g. with a cheaper price. This works by adding more rewards in addition to the product itself (if it's a non-consumable). Note that it is usually not a good idea to mix & match consumable and non-consumable rewards, as users might try to restore them multiple times in order to receive an endless amount.


The scene contains the Window – Preview prefab to display the bundle's contents.

11 RestoreTransactions

This scene has two buttons:

  • Clear Local Data: this button clears all local storage but also all internal transactions saved by Unity IAP, so they can be re-processed and treated as new transactions when restored. This should not be used in a production app and is only here for debugging purposes
  • Restore Transactions: having a restore button in your game is mandatory, so users can easily re-claim their previous purchases. Note that all progress earned and saved locally via the DBManager is lost in case of app uninstall, as well as consumable purchases, since the App Stores do not keep track of them

Custom Extension Scenes


The default shop scenes don't work in Virtual Reality for two reasons: input is not a regular click or touch and the UI canvas needs to be in world space. That's why this scene is separate, along with an additional shop item prefab: IAPItemVR. Components of XR Interactin Toolkit have been used in order to support VR devices. To give you a brief overview of the mechanics used for this scene:

  • The default XROrigin and XRInteractionManager components of XR Interaction Toolkit has been used
  • In order to receive raycast responses from VR controllers on UI elements in the scene, the TrackedDeviceGraphicRaycaster component has been added to the main Canvas, the buy button of IAPItemVR and all buttons on the purchase windows (in game objects: Window - Purchase, Window - Message, Window - Confirm)
  • On the hand controllers, XRRayInteractor component, the Max Raycast Distance variable was increased so that the ray can actually reach to the UI elements

For setup instructions and required packages to get this VR sample scene running, please see the VR sample scene guide for more details.


When using PlayFab, the first scene of your app should offer the possibility to sign-in your users (unless you are using PlayFab for Validation Only). This example scene provides a sample login form. Besides the IAPManager prefab, it also contains the PlayFabManager prefab.

The most important part in this scene are the slightly modified IAPManager settings. Since when logging in, we receive all product data and user inventory from PlayFab, the IAPManager should not initialize itself at app launch, but wait for PlayFab to finish initialization. Additionally, we would not want to save any data locally, and keep everything on PlayFab’s servers instead. For this reason, IAPManager's Auto Initialize checkbox is disabled and DBManager's StorageType = Memory.

Please see the PlayFab integration guide for more details.

ExampleScenes090 ExampleScenes091 ExampleScenes092