Ads Integration
Monetize your game with interstitial, rewarded, and banner ads.
Overview
The GameTribe SDK provides a unified ad system that works across all ad networks. Simply call the SDK methods and let the platform handle ad loading, display, and tracking.
| Ad Type | Description | Use Case |
|---|---|---|
| Interstitial | Full-screen ads shown at natural breaks | Level transitions, game over |
| Rewarded | Opt-in ads that give players rewards | Extra lives, bonus coins |
| Banner | Small persistent ads at screen edges | During gameplay or menus |
Interstitial Ads
Full-screen ads shown at natural break points in your game. A cooldown prevents showing ads too frequently.
InterstitialExample.cs
using UnityEngine;using GameTribe.SDK;public class InterstitialExample : MonoBehaviour{public void ShowLevelCompleteAd(){var callbacks = new AdCallbacks{OnAdShown = () =>{Time.timeScale = 0f;Debug.Log("Ad started showing");},OnAdClosed = () =>{Time.timeScale = 1f;Debug.Log("Ad closed");LoadNextLevel();},OnAdFailed = (error) =>{Debug.Log($"Ad failed: {error}");LoadNextLevel();}};PlatformSDK.Instance.Ads.ShowInterstitial("level_complete", callbacks);}}
Ad Cooldown
By default, interstitial ads have a 3-minute cooldown. Configure in Platform Config:
csharp
// In PlatformConfig asset:adCooldownSeconds = 180f; // 3 minutes (default)
Rewarded Ads
Opt-in ads where players choose to watch in exchange for rewards.
RewardedAdExample.cs
public void WatchAdForCoins(){var callbacks = new AdCallbacks{OnAdShown = () => Time.timeScale = 0f,OnRewardEarned = (rewardType, amount) =>{PlayerInventory.AddCoins(100);ShowRewardNotification("+100 coins!");},OnAdClosed = () => Time.timeScale = 1f,OnAdFailed = (error) => ShowError("Ad not available")};PlatformSDK.Instance.Ads.ShowRewarded("bonus_coins", callbacks);}
Always grant rewards in
OnRewardEarned, not OnAdClosed.Banner Ads
Small ads displayed at the edges of the screen.
csharp
// Show bannerPlatformSDK.Instance.Ads.ShowBanner(BannerPosition.Bottom);// Hide banner during gameplayPlatformSDK.Instance.Ads.HideBanner();
Banner Positions
| Position | Description |
|---|---|
| Top | Centered at top |
| Bottom | Centered at bottom |
| TopLeft | Top-left corner |
| TopRight | Top-right corner |
| BottomLeft | Bottom-left corner |
| BottomRight | Bottom-right corner |
Ad Callbacks
| Callback | Description |
|---|---|
| OnAdLoaded | Ad is ready to show |
| OnAdShown | Ad started displaying |
| OnAdClosed | Ad was dismissed |
| OnAdFailed | Ad failed (includes error message) |
| OnRewardEarned | Player completed rewarded ad |
Best Practices
- Natural break points — Show interstitials at level transitions
- Reward generously — Make rewarded ads worth watching
- Pause gameplay — Set
Time.timeScale = 0during ads - Handle failures gracefully — Always have a fallback