Skip to main content

Getting Started

Creating In-App Products in Unity

In Unity, the Project Settings tab is your main spot for managing IAPs, be it for real or virtual money.

GettingStarted010

TabDescription
CategoriesSpecify groups for your in-app products. Categories are used for separating several products into sections, which you can later instantiate into your shop UI.
CurrenciesDefine virtual currencies along with their starting amount, which can be used to purchase other virtual products in your app.
ProductsAdd in-app products that can be bought with real money (identifier must match your App Stores identifiers), in exchange for virtual currency (only exist within your app), or even physical goods using third-party payment providers.

For the Products tab, these are the variables which can be defined in the editor:

FieldDescription
IDYour unique product identifier.
TypeProduct type in the billing model.
Consumables : Can be purchased multiple times, for real money/currency (e.g. coins).
Non-Consumables : One-time purchase for real money/currency (e.g. bonus content).
Subscriptions : Periodically bills the user, for real money (e.g. service-based content).
TitleA descriptive title, assigned to the ShopItem's title Text component.
DescriptionA descriptive text, assigned to the ShopItem's description Text component.
IconA graphical visualization of the product, assigned to the ShopItem's icon component.
DiscountIf enabled, activates the discounted game object on the ShopItem instance after instantiation. When using third-party services (e.g. PlayFab), any remote discount will be detected automatically.
FetchWhether local product data should be overwritten by fetched App Store data (only applies to real money products). In addition, when using third party services (e.g. PlayFab), this applies to virtual products as well.
CostsPrice for real money / virtual currency, or other products that will be consumed on purchase. Not specifying a price will directly grant the product to the user locally.
RewardsAmount of virtual currency, or other products to be granted automatically. Please have a look at the sample scenes and compare the different settings for products that are non/consumables, consumed immediately or saved for later.

Instantiating Products in a Shop

The IAPContainer component in your shop scene will do all the work for you. Let’s have a look at it.

Open one of the example scenes, e.g. UniPay > Scenes > VerticalScroll

When you run the scene, the corresponding category IAPs are instantiated and parented to the container, and Unity's GridLayoutGroup component aligns them nicely on the ScrollView.

GettingStarted020

You only have to define what visual representation (Item Prefab) and from what group (Category) you want to instantiate your products. There are several pre-defined IAP Item prefabs to choose from, located in the UniPay > Prefabs > Vertical/Horizontal folders.

After instantiating the products as items in the scene, the IAPManager makes sure to set them to the correct purchase state, based on the user’s inventory. This means that the shop item for an already purchased product does not show the buy button anymore, or an equipped item has a button to deselect it again and so on.

note

You have now seen the basics of UniPay - it's Project Settings editor, where Categories, Products and Currencies are defined, and an example on how they can be used in a scene. Of course you can also drag an Item Prefab into the scene manually, without using the IAPContainer component, or build your own button that calls UniPay.IAPManager.Purchase(productID) directly (see the Buttons example scene for a sample). If you wish to take a UniPay deep dive, have a look at the Scripting Reference.

info

Before linking in-app products for real money in Unity, you have to create them in the App Store (Google Play, iTunes Connect, etc.) first. If this is the first time you get in touch with in-app purchases, continue with the store-specific guides for configurations on App Stores, or guides for third-party integrations.