🗺️ MonetizationManager

MonetizationManager – Component Overview

The MonetizationManager handles all in-app purchases (IAP) in the Virtual Pet Game Template. It supports consumable products, visual IAP data, and a fake purchase window for desktop and WebGL testing.


💰 What It Does

  • Initializes Unity IAP using the local Product Catalog

  • Handles real or fake purchases depending on the platform

  • Applies rewards (coins) based on configured product payouts

  • Displays a fake confirmation dialog when testing on PC/WebGL/Editor

  • Allows developers to localize product titles and assign icons per product


🔧 Inspector Fields

IAP Product Visual Data

  • iapVisualData – List of IAPItem entries:

    • productId: ID from the IAP catalog

    • productIcon: Sprite used in the store UI

    • titleTranslated: NameTranslatedByLanguage[] for title localization

Testing

  • useFakeShopOnPC – If enabled, shows a fake purchase dialog in non-mobile builds.


🛒 Runtime Behavior

Purchase Flow

To trigger a purchase:

MonetizationManager.Instance.Buy("product_id");
  • If the build is mobile: opens native store UI

  • If running on PC/WebGL and useFakeShopOnPC is enabled: shows fake shop popup

Purchase Rewards

  • When a product is purchased, its payouts are parsed.

  • If payout type is Currency, the corresponding coin is added to PlayerSave


🧪 Fake Shop (Testing)

Used on Editor, WebGL, or PC if useFakeShopOnPC is true:

  • Opens a confirmation popup using UIFakePurchaseConfirm

  • Simulates a payout (adds coins)

  • Useful for testing IAP visuals and logic without mobile store setup


🌍 Localization & Icons

  • GetTranslatedTitle(productId) – Returns localized title for a product

  • GetIconForProduct(productId) – Returns icon assigned in iapVisualData


✔️ Supported Platforms

  • Mobile platforms (iOS, Android) – real purchases

  • Editor, WebGL, Desktop – fake shop fallback (optional)


This component provides a fully customizable, offline-compatible IAP integration with localized UI support and safe fallback for development environments.

Last updated