<aside> <img src="/icons/reorder_gray.svg" alt="/icons/reorder_gray.svg" width="40px" />

Navigation

</aside>

🏠 Home Page

Getting Started

Architecture

Level System

Characters & Vehicles

Run Mechanics

World Objects

Boosters & Modifiers

Progression & Economy

UI

Save & Debugging

Modules

Publishing

Reference

💰 Monetization (Ads & IAP)

<aside> 💡 The template ships with a dummy ad provider and a placeholder product. Configure the real ad network and the store product before the release.

</aside>

Subsystems

ads-settings.png

iap-settings.png

SDKs prefab

Assets/Project Files/Game/Prefabs/SDKs.prefab is linked to the Initializer prefab. It holds the SDK behaviors:

Behavior Role
SDKInitializer Starts the SDK behaviors and registers the consent providers.
ATTTaskBehavior App Tracking Transparency request on iOS.
UMPTaskBehavior User Messaging Platform consent.
AdsSDKBehavior Initializes the ad provider.
IAPSDKBehavior Initializes the purchasing.

GameLoading calls Initializer.InitSDKs() after the modules are initialized.

Ads Settings

Assets/Project Files/Data/Ads Settings.asset.

Field Description
Active Provider The provider in use. The template uses Dummy, a test provider without real ads.
Debug Mode Enables the debug mode of the provider.
Test Devices Ids of the test devices.
Load Ads On Start Loads the first ads when the game starts.
Banner Enabled, Interstitial Enabled, Rewarded Video Enabled Enable each ad type. The banner is disabled in the template.
No Ads Reward Sprite Icon of the No Ads reward.
Interstitial First Start Delay Seconds before the first interstitial on the first launch (40).
Interstitial Start Delay Seconds before an interstitial after a start (40).
Interstitial Showing Delay Seconds between interstitials (30).
Loading Ad Duration, Loading Message The wait screen while an ad loads.
Provider Containers The ids of each provider.
Privacy Link, Terms Of Use Link Links opened by the settings page buttons. The buttons are hidden when a link is empty.

Provider containers in the template: AppLovin, AdMob (with Google test ids), Dummy and LevelPlay.

How to switch to a real ad network

  1. Install the SDK. Add the SDK of the provider to the project and enable the provider define in Define Manager.
  2. Select the provider. Set Active Provider in Ads Settings.
  3. Fill the ids. Enter the app id and the banner, interstitial and rewarded ids of the provider for Android and iOS. Replace the test ids before the release.
  4. Fill the legal links. Set Privacy Link and Terms Of Use Link.
  5. Test. Use Test Devices and Debug Mode.

AdsDummyModeBuildWarning warns before a build when the dummy provider is active.

Ads in the game

Place Behavior
UIRunResult, UILevelComplete x2 rewarded video, interstitial on Continue.
PreRunModifierSlot Rewarded video to activate a modifier.
InterstitialConditions A delegate on AdsManager for an extra condition.

AdsManager.ShowInterstitial respects the delays from Ads Settings and the forced ad state. Call it with ignoreConditions to skip the checks.

Remove Ads

  1. The player taps No Ads on the start screen. UINoAdsPopUp opens.
  2. The popup buys the NoAds product with IAPButton.
  3. After the purchase, AdsManager.DisableForcedAdForever() runs. Forced ads stop.
  4. UIStartScreen receives AdsManager.ForcedAdDisabled and hides the No Ads button.

The Reward No Ads asset in Data/Rewards is the reward that the product gives. Its Disable Ads Forever flag turns the ads off permanently. A reward can also disable the ads for a number of seconds.

IAP Settings

Assets/Project Files/Data/IAP Settings.asset.

Field Description
Use Fake Store Runs the purchase flow without a store. Use it in the Editor.
Fake Store Mode Result of a fake purchase.
Store Items The products.

A store item has:

Field Description
Android Id, iOS Id Product ids in the stores.
Product Key Type The ProductKeyType value.
Product Type Consumable, non-consumable or subscription.
Default USD Price Price shown before the store answers.
Rewards Set The reward given by the product.

The template has one product: NoAds, with the placeholder ids com.example.noads. Replace them with the ids of your stores before the release.

How to add a product

  1. Add a value to ProductKeyType in MD_ProductKeyType.cs.
  2. Add a store item to IAP Settings with the ids, the type and the price.
  3. Create a Reward asset and assign it to Rewards Set.
  4. Add an IAPButton with the product key to a page, or call IAPManager.BuyProduct(ProductKeyType).
  5. React to IAPManager.PurchaseCompleted.
IAPManager.BuyProduct(ProductKeyType.NoAds);

IAPDummyModeBuildWarning warns before a build when the MODULE_IAP define is not set.

The Restore button of the settings page calls IAPManager.RestorePurchases(). It is visible when the Purchasing module is initialized.

Consent

ATTTaskBehavior and UMPTaskBehavior show the consent flows at start. ConsentData collects the providers. Test them on a device with the real regions before the release.