Develop

Getting started with monetization in Unity

Updated: May 1, 2026
Monetization features enable you to sell content or services that enhance your app’s user experience. Think about monetization early in your app development process to effectively plan engagement methods and revenue sources for your app.
See our Monetization overview for a detailed explanation of the monetization features available to you.
This guide shows you how to get started with monetizing a Meta Quest app built with Unity. By following this guide, you’ll learn:
  • How to enable in-app purchases (IAP) in the Developer Dashboard.
  • How to set up an IAP in your Unity app.

Prerequisites

Account requirements

Software requirements

Headset requirements

  • Supported Meta Quest headsets:
    • Quest 2
    • Quest Pro
    • Quest 3
    • Quest 3S and 3S Xbox Edition

Project setup

Before working on implementing an IAP, make sure your project is properly set up by completing the following sections:

How to implement an in-app purchase (IAP)

Step 1: Indicate that your app needs an internet connection

Step 2: Enable in-app purchases

Complete the steps in Enable in-app purchases.

Step 3: Create an add-on in the Developer Dashboard

Follow the steps in Setting up add-ons to create a Consumable IAP in the Developer Dashboard. Set the price of the add-on to free so you can test the purchase flow without incurring charges.
Once your add-on is published, you can start referencing it in your Unity project.

Step 4: Add a UnityXR Interaction Camera and Rig

  1. Open your project in the Unity Editor.
  2. In the Hierarchy tab, right-click on the default Main Camera and click Delete.
    Deleting the default Main Camera from the Hierarchy
  3. Right-click in the Hierarchy tab. Go to Interaction SDK > Add UnityXR Interaction Rig.
    Selecting Add UnityXR Interaction Rig from the Interaction SDK menu
  4. In the Unity XR Comprehensive Rig Wizard, click Fix All.
    Unity XR Comprehensive Rig Wizard with Fix All button
  5. Click Create to add the UnityXRCameraRig to your scene.
    Unity XR Comprehensive Rig Wizard with Create button

Step 5: Add UI elements

  1. Right-click in the Hierarchy tab. Go to GameObject > UI > Canvas. A Canvas is added to your project’s Hierarchy.
    Creating a UI Canvas in the Hierarchy
  2. In the Hierarchy, select the Canvas. In the Inspector tab, set Render Mode to World Space.
    Canvas Inspector with Render Mode set to World Space
  3. Under Rect Transform, set the following values:
    • Rect Transform > PosX: 0
    • Rect Transform > PosY: 1.15
    • Rect Transform > PosZ: 1.5
    • Rect Transform > Width: 480
    • Rect Transform > Height: 720
    • Rect Transform > Scale: [0.0005, 0.0005, 0.0005]
    Canvas Rect Transform settings in the Inspector
  4. Right-click the Canvas in the Hierarchy tab. Go to UI (Canvas) > Panel. A Panel is added to your project’s Hierarchy.
    Creating a UI Panel under the Canvas in the Hierarchy
  5. Right-click the Panel. Go to UI (Canvas) > Button - TextMeshPro. A Button is added to your project’s Hierarchy.
    Creating a Button under the Panel in the Hierarchy
  6. Click on Button in the Hierarchy tab. On the Inspector tab, under Rect Transform, set the following settings:
    • Width: 300
    • Height: 100
    Button Rect Transform settings with Width and Height values
  7. Under Button in the Hierarchy tab, click Text (TMP).
  8. Under the Inspector tab for Text, under Text Input, enter Buy IAP.
    Button Text Input field in the Inspector with Buy IAP text
The Canvas panel should now look something like this:
Canvas panel with Buy IAP button

Step 6: Add Ray Interaction

  1. In the Hierarchy tab, right-click on the Canvas. Go to Interaction SDK > Add Ray Interaction to Canvas.
    Adding a Ray Interaction to the Canvas in the Unity project
  2. In the Ray Canvas Wizard window, click Create.
    The Ray Canvas Wizard with the create button

Step 7: Create a new script

  1. In the Project window, right-click on the Assets folder.
    Asset folder in the project window
  2. In the menu, navigate to Create > Scripting > Empty C# Script. This creates a new C# script called NewEmptyCSharpScript.cs in the Assets folder.
    Create an empty C# script in the Assets folder
  3. Rename the script IAPManager.cs.
  4. Double-click the script in the Assets folder to open it in your code editor.
    Empty IAPManager script in the Assets folder
  5. Replace the content with the following code snippet:
     using UnityEngine;
     using Oculus.Platform;
     using Oculus.Platform.Models;
    
     public class IAPManager : MonoBehaviour
     {
         private const string APP_ID = "YOUR_APP_ID";
         private const string IAP_SKU = "YOUR_IAP_SKU";
    
         void Start()
         {
             Core.Initialize(APP_ID);
    
             // Recommended: on startup, also reconcile any unconsumed purchases:
             // IAP.GetViewerPurchases().OnComplete(OnViewerPurchases);
         }
    
         public void OnClickButton()
         {
             BuyItem(IAP_SKU);
         }
    
         // Launch the checkout flow for a given SKU
         public void BuyItem(string sku)
         {
             IAP.LaunchCheckoutFlow(sku).OnComplete(OnPurchaseComplete);
         }
    
         // callback for purchase
         private void OnPurchaseComplete(Message<Purchase> msg)
         {
             if (msg.IsError)
             {
                 Debug.LogError(msg.GetError().Message);
                 return;
             }
    
             Purchase purchase = msg.Data;
             Debug.Log($"Purchased: {purchase.Sku}");
    
             // 1) First, grant the item/currency to the game user
             GrantConsumableToPlayer(purchase.Sku);
    
             // 2) Then, consume the item/currency
             IAP.ConsumePurchase(purchase.Sku).OnComplete(consumeMsg =>
             {
                 if (consumeMsg.IsError)
                 {
                     Debug.LogError($"Consume failed for {purchase.Sku}: {consumeMsg.GetError().Message}");
                     return;
                 }
    
                 Debug.Log($"Consumed: {purchase.Sku}");
             });
         }
    
         private void GrantConsumableToPlayer(string sku)
         {
             // Example: add currency / increment count locally (or via your backend).
             Debug.Log($"Granting consumable to player for sku={sku}");
         }
     }
    
  6. Replace the placeholder values in the code with your app’s credentials from the Developer Dashboard:
    • Set APP_ID to your App ID. For example, if your App ID is 12345:
     private const string APP_ID = "12345";
    
    • Set IAP_SKU to the SKU of the add-on you created. For example, if your IAP’s SKU is 678910:
     private const string IAP_SKU = "678910";
    

Step 8: Add the checkout functionality to the UI button

  1. Drag and drop the script from the Project window onto the Canvas in the Hierarchy window.
    Dragging script to Canvas in the Hierarchy window
    The Inspector window now shows the script attached to the Canvas.
    Script attached to Canvas in the Inspector window
  2. Click Button in the Hierarchy window to open the Inspector window.
  3. In the Inspector window, under the On Click() section, click the Select Object button.
    Select Object button in the On Click section of the Inspector window
  4. In the Select Object window, switch to the Scene tab and select Canvas. To filter the list, type Canvas in the search field.
    Select Object window with Scene tab and Canvas selected
  5. In the Function dropdown, select IAPManager > OnClickButton().
    Function dropdown with IAPManager and OnClickButton selected

Step 9: Build your app

  1. In the top menu bar, go to File > Build Profiles.
  2. In the Build Profiles window, under Platforms in the left nav menu, make sure Meta Quest is active.
    Build Profiles window with Meta Quest platform active
  3. If your scene is not already in the Scene List, click Open Scene List to add it to the build. Deselect and remove any other scenes from the selection window.
    Build Profiles Scene List with Open Scene List button
  4. Click Build.
    Build Profiles window with Build button
  5. In the Build Android window that appears, select a location to save your APK. Remember the location of the APK.
  6. Click Save.
    Build Android window with save location selection

Step 10: Upload APK using Meta Quest Developer Hub

Complete the steps in Uploading your app through the Meta Quest Developer Hub. When uploading the APK to Meta Quest Developer Hub, make sure to select the ALPHA release channel of your app.

Step 11: Deploy your APK from the release channel to your headset

  1. Ensure your headset is connected to your computer and recognized by the Meta Quest Developer Hub. For setup instructions, see Device Setup.
  2. In the Meta Quest Developer Hub, navigate to your app’s distribution page. On the ALPHA Release Channel, click the menu button.
    Menu button on the Alpha Release Channel in Meta Quest Developer Hub
  3. Click Install build on device and select your headset.
    Select headset for install dialog in Meta Quest Developer Hub

Step 12: Launch your APK

  1. Put on your headset.
  2. Press the Meta button on your right Quest controller.
  3. Click the Library icon.
    Library icon in Meta Quest menu
  4. Find your app in the Library and click on it.
    IAP app in the Meta Quest Library
  5. When the app launches, click Buy IAP.
  6. Since the add-on you created is a free consumable, the menu appears and then quickly disappears because the transaction automatically completes.
    IAP test app window showing the Buy IAP button and purchase flow

Step 13: Verify your purchase in device logs

  1. While your headset is connected to your computer, open the Meta Quest Developer Hub.
  2. In the left nav menu, click Device Manager.
    Device Manager in the Meta Quest Developer Hub left nav menu
  3. In the Device Manager window, click Device Logs for your connected headset.
    Device Logs button in the Device Manager window
  4. In the Device Logs window, switch the dropdown to Debug.
    Debug dropdown in the Device Logs window
  5. In the search bar, enter Purchased.
    Purchased search term in the Device Logs search bar
  6. With the Device Logs window still open, launch the app on your headset.
  7. Click the Buy IAP button.
  8. Look at the Device Logs window for a log line confirming that the purchase was successful.
    Log message confirming a successful purchase
You have now successfully implemented IAP in your Unity project.

Learn more

Explore the resources below to continue learning about IAP, add-ons, and other monetization and platform features.