Unity Ads
- Game Development course
- Expert
- Lesson 38/47
- 4 min
Learn to show ads with Unity Ads.
What Is Unity Ads?
Unity Ads is an advertising solution that helps generate revenue by displaying ads in Unity games. Players can be shown different ad formats, such as banners, interstitial ads, or rewarded ads. To display ads, the relevant service must be configured in the project and an appropriate ad unit must be used.
Ad Service
Banner
Interstitial
RewardedShowing ads at appropriate moments is important for the player experience.
Starting an Advertisement
To display an advertisement, the ad service must first be initialized and the ad must be loaded. When the ad is ready, the appropriate display method is called. For example, an ad provider API may include a method similar to Show.
if (adReady)
{
ShowAd();
}ShowAd is an example method name; in actual use, the call must match the API of the installed advertising package.
Practice Create an Advertisement Display Flow
Create a MonoBehaviour class named AdDisplayExample. In the Start method, define a bool variable indicating that the ad is ready. If the variable is true, call the ShowAd method. Also define the method inside the class and print an advertisement display message to the console.
Starter code
using UnityEngine;
public class AdDisplayExample : MonoBehaviour
{
void Start()
{
// Reklamın hazır olduğunu belirt
// Hazırsa ShowAd metodunu çağır
}
// ShowAd metodunu burada tanımla
}Sample solution
using UnityEngine;
public class AdDisplayExample : MonoBehaviour
{
void Start()
{
bool adReady = true;
if (adReady)
{
ShowAd();
}
}
void ShowAd()
{
Debug.Log("Advertisement shown");
}
}Expected output
Advertisement shown
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What is the main purpose of using Unity Ads?
- To speed up physics calculations
- To create game characters
- To generate revenue by displaying advertisements Correct answer
- To configure scene lighting
Explanation: Unity Ads helps generate revenue through advertisement displays inside a game.
2 Choose the Advertisement Display Method
if (adReady)
{
____();
}
if (adReady)
{
ShowAd();
}
Explanation: ShowAd is an example method name used to start displaying an ad when it is ready.
3 Advertisement Display Stages
| Term | Meaning |
|---|---|
Initialize |
Initializes the ad service |
Load |
Prepares the advertisement content |
Show |
Displays the ready advertisement |
Ad Unit |
Identifies the ad placement |