πŸ“’Generic Ad Manager

This Manager doesn't require any ad packages before using API. So you can leave AdManager calls in your game and then just add AdNetwork implementation in the end.

Package (DOTween)
Package (PrimeTween)

How to use

Replace AdManager.prefab in loader scene.

Add placement names to AdPlacements enum (in AdManager.cs file). for example LevelContinue, RewardCoins

Add AdNetwork implementation script as component to AdManager prefab in inspector and reference it to ActiveNetwork field. Use existing AdNetwork implementations Or implement your custom one -> Implementing custom AdNetwork

Call ads

Call reward/inter/banner methods from AdManager.Instance where you need.

// AdManager Reward/Interstitials methods works with callbacks
// and callback will be invoked even if there is no ads to keep game flow

public void OnContinueButtonClick() {
    AdManager.Instance.ShowInter(AdPlacements.LevelContinue, LoadNextLevel);
}

private void LoadNextLevel() {
    // actions for new level load
}

You can pass string to ShowInter or Rewarded as well. But we recommend to use enum for consistency

Use AdButton for rewards

You can use AdButton.cs script with rewarded button (add it as new component to button object) to update it's interactible state (by default).

How it looks in inspector
  • Placement field is used with AdNetwork. Some ad networks use them to lock rewards for a while and for analytics.

  • inherit it and override OnRewardedReadyStateChanged(bool isReady) to implement custom visuals change logic.

  • You can change placement name runtime with ChangePlacement() method.

Or you can write code as below:

// snippet how to toggle button state depending on reward ad ready

// to test button active state you need to run game from loader,
// because AdManager has reference to network, but if you start play from other scene
// so you have skipped loader scene
// then AdManager object will be created runtime without references
// (it's only case in editor while testing)

if (AdManager.Instance.IsEnabled) {
    if (AdManager.Instance.IsRewardedReady(AdPlacements.GetAdCoins)) {
        SetAdButtonActiveState();
    }
    else {
        // you can subscribe to reward ready event here
        // AdManager.OnRewardAdLoaded.AddListener(SetAdButtonActiveState);
        // then avoid listener dublicates if this can be called multiple times without this monobehaviour object destroy
        
        SetAdButtonDisabledState();
    }
}
else {
    SetAdButtonDisabledState();
}

Use Interstitial coffee break ad

This is simillar to insterstitial ad, but with warning for player that soon will be ad.

Default visuals for coffee break interstitial
// with callback example
AdManager.Instance.ShowInterCoffeeBreak(AdPlacements.LevelContinue, () => {
    // give player little reward or change level and etc
});

// do nothing after ad example
AdManager.Instance.ShowInterCoffeeBreak(AdPlacements.LevelContinue, null);

You can change AdCoffeeBreak.prefab visuals to fit your game.

Interstitials delay between

AdNetwork implementations

MAX AppLovin Ads
Clever Ads Solution
Appodeal

Last updated