Getting Started
Overview
The Mobile Monetization Plugin is a comprehensive solution that combines Advertisement, In-App Purchases (IAP), Offerwalls, and System utilities into a unified framework. It handles initialization order, SDK dependencies, and cross-platform compatibility, allowing you to focus on gameplay logic.
Installation
Via Unity Package Manager (Recommended)
- Open Window > Package Manager.
- Click the + button in the top-left corner > Add package from git URL….
- Paste the following link:
https://github.com/Mafty63/Mobile-Monetization.git?path=/Assets/Mobile Monetization - Click Add.
The package will appear in your Packages folder (not Assets) under Mobile Monetization.
Import Samples
To avoid creating settings from scratch, we recommend importing the samples:
- In Package Manager, select Mobile Monetization.
- Go to the Samples tab.
- Click Import next to Examples and Resources.
- This adds pre-configured settings and prefabs to
Assets/Samples/Mobile Monetization/[Version]/Examples and Resources/.
1. Core Setup (Main System)
The Main System acts as the brain of the plugin, initializing all other modules in the correct order.
Setup Steps
- Prepare Settings:
- Option A (Recommended): Use the
MainSystemSettingsfound in the imported Samples folder. - Option B (Manual): Right-click in Project view >
Mobile Core>Main System Settings.
- Option A (Recommended): Use the
- Assign Modules (If creating manually):
- Set Core Module to your
SystemModuleInitializerasset. - Add other modules (Ads, IAP, Offerwall) to the Modules list.
- Set Core Module to your
- Scene Setup:
- In your first scene (Splash/Loading), add an empty GameObject.
- Add the
MainSystemManagercomponent. - Drag the
MainSystemSettings(from Samples or created manually) into the Init Settings slot. - This object will persist (
DontDestroyOnLoad) automatically.
2. Enabling Third-Party SDKs (Define System)
This plugin uses a smart Define System to automatically toggle code based on installed SDKs.
- Install SDK: Import your third-party SDKs (e.g., AdMob, Unity Ads, LevelPlay, Unity IAP, etc.) into the project.
- Enable Defines:
- Go to
Tools > MobileCore > Define Symbols Manager. - Click Refresh All Define Symbols.
- The system will scan your project for the SDK classes (configured in
Assets/Mobile Monetization/Define System/) and automatically add the necessary Scripting Define Symbols to Player Settings.
- Go to
3. Advertisement Setup
Unified API for AdMob, Unity Ads, IronSource (LevelPlay), AppLovin, and more.
- Enable Module:
- Open your
Main System Settingsasset. - Under the MODULES section, look for Advertisement Module.
- If it’s missing, click Add Module > Advertisement Module.
- Click the ENABLE/DISABLE button to ensure it reads DISABLE (meaning it is currently ENABLED) or check if the section is expanded and active. Actually, the button label shows the action to take, so if it says “DISABLE”, it is currently Enabled. ensure the module is Enabled.
- Open your
- Assign Settings:
- Expand the Advertisement Module configuration.
- Locate the Settings field (
AdsSettings). - Drag your
AdsSettingsasset (from Samples or created manually) into this slot. - Crucial: If this slot is empty, the Ads Manager will fail to initialize.
- Configure Providers:
- Select the
AdsSettingsasset itself. - Enable providers for Banner, Interstitial, and Rewarded.
- Privacy: Configure GDPR and IDFA settings in the “Privacy & Compliance” foldout.
- Timing: Adjust interstitial delays and auto-show behavior in “Interstitial Timing”.
- Select the
- Configure Providers in AdsSettings:
- Select the
AdsSettingsasset (or click OPEN ADS SETTINGS in the Module Inspector). - Important: Ensure your desired provider’s Define Symbol is active (see Section 2). If the symbol (e.g.,
ADMOB_INSTALLED) is not active, the provider will not appear in the configuration tabs or dropdowns. - Provider Settings: Use the tabs to configure specific settings for each provider (e.g., AdMob App ID, Unity Ads Game ID).
- Ad Type Selection: In the “Ad Type Providers” section, select which provider to use for each ad format (Banner, Interstitial, Rewarded).
- Select the
4. In-App Purchases (IAP) Setup
Wrapper around Unity IAP for easier product management.
- Enable Module:
- Open
Main System Settingsand find In-App Purchase Module. - Ensure the module is Enabled.
- Assign your
IAPSettingsasset to the Settings slot.
- Open
- Define Product Keys:
- Open your
IAPSettingsasset (or click OPEN IAP SETTINGS in the Module Inspector). - Click the Edit ProductKeyType Enum button.
- Add your internal product keys (e.g.,
REMOVE_ADS,COIN_PACK_SMALL). These keys act as safe references in your code.
- Open your
- Configure Products:
- In
IAPSettings, click Add Product to create a new item. - The inspector uses a custom drawer (
IAPItemDrawer) for clear configuration:- Type: Select Consumable, NonConsumable, or Subscription.
- Key Type: Select the internal key you defined in step 2.
- Android ID & iOS ID: Enter the store-specific IDs (e.g.,
com.game.coinpack).
- In
5. Offerwall Setup
Integration for Offerwall providers like Tapjoy.
- Enable Module:
- Open
Main System Settingsand find Offerwall Manager. - Ensure the module is Enabled.
- Assign your
OfferwallSettingsasset to the Settings slot.
- Open
- Configure Offerwall:
- Open your
OfferwallSettingsasset (or click OPEN OFFERWALL SETTINGS in the Module Inspector). - General Settings: Enable Test Mode and System Logs as needed.
- Tapjoy Configuration:
- Configure your Tapjoy keys in the container fields.
- Note: If you haven’t installed the SDK, click the Download Tapjoy SDK button to get the latest version (v13.x+ recommended).
- Open your
6. System Utilities
Helper tools for device configuration and common UI actions.
1. Core Configuration
The Core Module (assigned in Main System Settings) provides essential device settings:
- Frame Rate: Configure target frame rates for default and battery-saving modes, or set to Auto to match the screen’s refresh rate.
- Sleep Timeout: Control device sleep behavior (e.g., set to “Never Sleep” to keep the screen on during gameplay).
2. UI Helpers (SystemManager)
Static methods to access the built-in system canvas for feedback:
// Show a floating "toast" message
SystemManager.ShowMessage("Level Completed!", 2.5f);
// Blocking Loading Screen
SystemManager.ShowLoadingPanel();
SystemManager.ChangeLoadingMessage("Downloading Assets...");
// ... async operation ...
SystemManager.HideLoadingPanel();
Next Steps
For detailed API documentation on the major revenue modules, see:
- Settings: Core | Ads | IAP
- API: Ads Reference | IAP Reference