Scripting Reference
Namespace: MobileCore.Advertisements
AdsManager Class
The primary entry point for all advertising logic.
General Methods
| Method | Description |
|---|
Initialize(AdsManagerInitializer) | Initializes the module manually (usually handled by MainSystem). |
IsModuleEnabled(AdProvider) | Checks if an ad module state is not disabled in the setting. |
IsModuleActive(AdProvider) | Checks if a specific provider belongs to active handlers dictionary. |
IsModuleInititalized(AdProvider) | Checks if a specific provider is fully initialized. |
ShowErrorMessage() | Displays a generic “Network error” toast message. |
TryToLoadFirstAds() | Manually triggers the initial load of ads. |
General Methods
Banner Ads
| Method | Description |
|---|
ShowBanner() | Displays the banner ad. |
HideBanner() | Hides the banner ad and resets the auto-show timer. |
DestroyBanner() | Completely removes the banner instance from memory. |
EnableBanner() | Sets banner state to active and shows it. |
DisableBanner() | Sets banner state to inactive and hides it. |
Banner Ad Methods
Fields:
float BannerAutoShowDelay: Time in seconds to automatically reshow a hidden banner (0 to disable).
Interstitial Ads
| Method | Description |
|---|
IsInterstitialLoaded() | Returns true if an ad is ready to show. |
IsInterstitialLoaded(AdProvider) | Returns true if an ad is ready to show for a specific ad provider. |
ShowInterstitial(InterstitialCallback, bool) | Shows ad. ignoreConditions bypasses time delays (default is false). |
RequestInterstitial() | Manually requests a new ad fetch. |
SetInterstitialDelayTime(float) | Sets the delay (in seconds) before the next interstitial can be shown. |
ResetInterstitialDelayTime() | Resets the delay timer to the default value from Settings. |
Interstitial Ad Methods
Rewarded Ads
| Method | Description |
|---|
IsRewardBasedVideoLoaded() | Returns true if an ad is ready. |
ShowRewardBasedVideo(RewardedVideoCallback, bool) | Shows ad. showErrorMessage toggles toast error messages (default is true). |
RequestRewardBasedVideo() | Manually requests a new ad fetch. |
Rewarded Ad Methods
No Ads / Forced Ads
Use these methods to implement “Remove Ads” functionality.
| Method | Description |
|---|
DisableForcedAd() | Permanently disables Banners and Interstitials (saves state to PlayerPrefs). |
IsForcedAdEnabled(bool) | Returns true if ads are allowed to show. useCachedValue bypasses checking PlayerPrefs (default is true). |
Forced Ads Methods
Privacy (GDPR & IDFA)
| Method | Description |
|---|
SetGDPR(bool) | Sets the user’s consent status (true = consent given). |
GetGDPRState() | Returns the current consent status. |
IsGDPRStateExist() | Returns true if the GDPR player pref is already set. |
IsIDFADetermined() | Returns true if the user has granted permission for IDFA tracking on iOS devices. |
Privacy Methods
Events
Subscribe to these events to react to ad lifecycle changes.
// Global Ad Lifecycle
AdsManager.AdLoaded += (provider, type) => Debug.Log($"{type} Loaded");
AdsManager.AdDisplayed += (provider, type) => Debug.Log($"{type} Displayed");
AdsManager.AdClosed += (provider, type) => Debug.Log($"{type} Closed");
// Banner Specific
AdsManager.BannerShown += () => Debug.Log("Banner UI Visible");
AdsManager.BannerHidden += () => Debug.Log("Banner UI Hidden");
// Status Changes
AdsManager.ForcedAdDisabled += () => Debug.Log("Ads Removed via IAP");
// Custom Logic Conditions
// Return false to prevent interstitials (e.g., during tutorials or loading)
AdsManager.InterstitialConditions += () => {
return !TutorialManager.IsActive;
};