π’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.
How to use
Replace AdManager.prefab in loader scene.
Add placement names to AdPlacements enum (in AdManager.cs file).
for example LevelContinue, RewardCoins
// todo implement check ..
Implement these lines in AdManager.cs where it's replaced. Every game has it's own logic for game number, first start (you could determine first start always if player didn't finish tutorial and etc).
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
}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).

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.

// 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
Use Ads Settings.asset scriptable object to define ad cooldown / delays for intersitial (after rewarded, between interstitial, on app launch).
Note, that if rewarded ad watched -> interstitial cooldown will be overridden to cooldown value after rewarded ad.
You can use Generic Ad Manager with this manager to retrieve ad settings from unity dashboard remote config page.
Setup:
Add Generic Ad Manager, don't remove it's default fields (AdDelays, EnableAd and etc)
add REMOTE_CONFIG_UNITY script symbols in Player settings located "Other Settings" section.
AdNetwork implementations
Last updated