Virtual Pet Game Template
  • VIRTUAL PET GAME TEMPLATE
  • Getting Started
    • ๐ŸŽฏ Project Setup Guide
    • ๐Ÿงฉ Home Scene Overview
    • ๐Ÿ—บ๏ธ UI Main Menu
    • ๐Ÿ—บ๏ธ LoadingManager
    • ๐Ÿ—บ๏ธ GameInstance
    • ๐Ÿ—บ๏ธ ToolsManager
    • ๐Ÿ—บ๏ธ AudioManager
    • ๐Ÿ—บ๏ธ LanguageManager
    • ๐Ÿ—บ๏ธ MonetizationManager
    • ๐Ÿ—บ๏ธ PlayerSave
  • Modifying the project
    • ๐Ÿพ How to Add a New Pet
    • ๐Ÿ“œHow Add a New Pet Rules
    • ๐Ÿ’ฐ How to Add a New Currency
    • ๐ŸŽ How to Add a New Food Item
    • ๐Ÿงข Adding a New Accessory
    • ๐ŸŽฎ How to Add a New Minigame
  • Modifying Minigames
    • ๐ŸŒค๏ธ Minigame "Jump Sky"
    • ๐Ÿ” Minigame "Food Flicker"
    • ๐Ÿฆ Minigame โ€œFlappyโ€
    • ๐Ÿ’Ž Minigame โ€œGem Hunterโ€
Powered by GitBook
On this page
  • ๐Ÿ’ฐ What It Does
  • ๐Ÿ”ง Inspector Fields
  • ๐Ÿ›’ Runtime Behavior
  • ๐Ÿงช Fake Shop (Testing)
  • ๐ŸŒ Localization & Icons
  • โœ”๏ธ Supported Platforms
  1. Getting Started

๐Ÿ—บ๏ธ 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.

Previous๐Ÿ—บ๏ธ LanguageManagerNext๐Ÿ—บ๏ธ PlayerSave

Last updated 28 days ago