Monetize your mobile games!
Why Monetize with Unity Ads?
Monetization is a crucial step for game developers looking to support and grow their projects. Unity Ads offers a hassle-free way to add various ad formats, such as interstitials, rewarded videos, and banners, enhancing both user experience and revenue potential.
Preview
Step 1: Enable Unity Ads in Your Unity Project
- Open Window → General → Services.
- Sign in or create a Unity account.
- Click Create Project ID under your organization and ensure Ads are turned ON.
- If the Advertisement package isn't installed automatically, use Window → Package Manager to install it manually.
- Tip: If your game is for kids under 13, mark it as child-directed when asked.
Step 2: Switch Your Build Target
Unity Ads works only on Android and iOS:
- Go to File → Build Settings.
- Select Android or iOS and click Switch Platform.
- Wait for Unity to process—once done, the platform's logo appears next to your target.
Step 3: Configure Ads in the Unity Dashboard
- Open the Services tab, click Go to Dashboard.
- Select your project, enable Ads, and choose No mediation.
- Add three ad placements:
videofor interstitialsrewardedVideofor rewarded adsbannerfor banner ads
- Copy your Game IDs (Android/iOS) and Placement IDs for later steps.
Preview
Step 4: Script Integration—Your AdsManager
Create a C# script called AdsManager.cs and attach it to a GameObject (like Main Camera).
C#1using UnityEngine;
2using UnityEngine.Advertisements;
3
4public class AdsManager : MonoBehaviour, IUnityAdsListener {
5#if UNITY_IOS
6 string gameID = "YOUR_IOS_GAME_ID";
7#else
8 string gameID = "YOUR_ANDROID_GAME_ID";
9#endif
10 void Start() {
11 Advertisement.Initialize(gameID);
12 Advertisement.AddListener(this);
13 }
14 // Interstitial
15 public void PlayAd() {
16 if (Advertisement.IsReady("video"))
17 Advertisement.Show("video");
18 }
19 // Rewarded
20 public void PlayRewardedAd() {
21 if (Advertisement.IsReady("rewardedVideo"))
22 Advertisement.Show("rewardedVideo");
23 else Debug.Log("Rewarded ad not ready!");
24 }
25 public void OnUnityAdsDidFinish(string placementId, ShowResult result) {
26 if (placementId == "rewardedVideo" && result == ShowResult.Finished)
27 Debug.Log("Player rewarded!");
28 }
29 // Banner
30 public void ShowBanner() {
31 if (Advertisement.IsReady("banner")) {
32 Advertisement.Banner.SetPosition(BannerPosition.BOTTOM_CENTER);
33 Advertisement.Banner.Show("banner");
34 } else StartCoroutine(RepeatShowBanner());
35 }
36 IEnumerator RepeatShowBanner() {
37 yield return new WaitForSeconds(1);
38 ShowBanner();
39 }
40 public void HideBanner() => Advertisement.Banner.Hide();
41}
42
Step 5: Connect Ad Logic to Your Game
Open your main game script (e.g., GameManager.cs) and link the AdsManager:
C#1public AdsManager ads;
2
3void Start() {
4 ads.ShowBanner();
5}
6void GameOver() {
7 ads.PlayAd();
8}
9void DoubleScore() {
10 ads.PlayRewardedAd();
11}
12
Then drag the AdsManager GameObject into the public field in the Unity Inspector.
Step 6: Test and Launch!
- Use Play Mode and trigger ads via gameplay or test buttons.
- Interstitials show up between levels.
- Rewarded ads play for double rewards or bonuses.
- Banners stay visible and can be hidden anytime.
- Always test on a real device for live ads—Unity Editor uses test mode!
Congratulations—you’ve just turned your mobile game into a money-making machine with Unity Ads!
