About

The Ads Module is a core part of the EKStudioCore library (EKStudio.Monetization). It is not custom-written for this specific game project, but rather a reusable monetization framework integrated into the game template.

It manages Banners, Interstitials, and Rewarded Watch Ads, switching between production ad networks (AdMob, Unity Ads, LevelPlay) and a local editor simulator (Mock Ad Network).

Key Components

AdvertisingSystem.cs - The static core manager responsible for initializing ad providers, caching/loading ads, verifying timing delays, showing ads, and executing callbacks.

AdRewardButton.cs - A generic, drop-in UI Button component to easily link a rewarded watch ad to any gameplay action with optional cooldowns and callbacks.

AdConfiguration.cs (ScriptableObject) - Stores configuration settings like selected providers, ad unit IDs, and timing/frequency variables.

MockAdNetwork.cs & AdMockController.cs - Local simulated ad networks that generate dummy overlay screens in the Unity Editor for seamless testing without SDKs.

Usage

1. Show Rewarded Ad (Code-based)

Use AdvertisingSystem.ShowRewardBasedVideo to request a rewarded ad with a success callback:

using EKStudio.Monetization;

public void OnWatchAdToDoubleCoins()
{
    // Optionally disable the button to prevent multiple clicks
    doubleCoinsButton.interactable = false;

    AdvertisingSystem.ShowRewardBasedVideo((bool success) =>
    {
        if (success)
        {
            // Give reward (e.g., Add coins, revive player, grant items)
            SaveManager.Coins += levelReward;
            UpdateUI();
        }
        else
        {
            // Re-enable button on failure/dismissal
            doubleCoinsButton.interactable = true;
            WarningManager.Instance.ShowWarning("Ad not available. Try again later.");
        }
    });
}

2. Using AdRewardButton (Inspector-based)

image.png

To add rewarded ads to custom UI buttons without writing code:

  1. Attach the AdRewardButton component to a Unity UI Button.
  2. Configure Cooldown Time if needed (persists automatically in PlayerPrefs).
  3. Set the optional statusTextTMP to automatically display "Watch Ad", "Loading...", or cooldown timers.
  4. Hook your reward logic directly into the On Ad Watched Success UnityEvent.