Unity 3D-Advertising Integrations

In this blog post, I will try to explain the integration of various advertising integrations for Unity for both IOS and Android platforms. I am using these tools that I will explain in the project I am currently actively working on.

First of all, I will touch on advertising integrations. At this stage, I will offer you 2 options. These options; Google Admob and Unity Ads. Let's start with Google Admob:

  1. Google Admob Integration for Unity

Sources I used while writing the article 1 and 2 I add.

The first thing you need to do is from this address Downloading GoogleMobileAds.unitypackage:

Then create a new account (Sign up) from the AdMob website (Gmail account required) or log in to the system with your existing account (Sign in).

After creating your account and logging in to the system, follow Apps - Add App from the menu on the left and add a new application to your account. To add ads to the application you just created, click Apps-Application_Name from the left menu. Select it and click Ad Units in the left menu.'Click on . Finally, click on the Add Ad Unit button on the screen that appears.

1.1 Banner Ads:

Select Banner as the ad type and enter an ad unit name. Finish the process by clicking the Create Ad Unit button.

1.2 Interstitial Advertisements:

They are known as full-screen interstitials. You can create it by following the instructions in the Banner Ads heading.

1.3 Rewarded Ads:

In this type of video ad, if the user watches the ad from start to finish, you need to reward the user in the game in some way (for example, by giving 100 gold). In this case, in the Reward settings, choose 100 as the Reward Amount and gold as the Reward Item. You can enter. Since the values you specify here go as parameters to your Unity code, you can dynamically change the number of gold that users earn by watching ads - without making any changes to your Unity code. Of course, if you wish, you can ignore these values and determine how many gold coins will be earned by watching the ad directly in your Unity code.

After creating your ad unit(s), finalize the process by clicking the Complete button. Click on the ad you just created from the ad units menu and click on Application Instructions at the top right on the screen that appears. Make a note of your app ID and ad unit ID that appear here (ca-app-pub- Don't forget to add the part!):

First, open your project in Unity. Then follow the path Assets>Import Package>Custom Package from the panel above. After importing the files to your project, right-click anywhere in the Project channel and select Play Services Resolver-Android Resolver-Resolve. process and wait until it is finished. Follow the path Assets-Google Mobile Ads-Settings…. Inspector Some settings will appear in the panel. From these settings, check Enabled under Google AdMob and enter your application ID in the space next to Android (no space characters at the beginning or end of the ID! Make sure there are no leading or trailing spaces when using your advertising IDs in your codes):

After these steps, let's come to the code side:

1.4 Ad Integrations

1.4.1 Banner Advertising Code Integration

Let's say you want to display a banner ad at the top of the screen in the first scene of the game. Then create a new C# script called Advertisement and drag this script to give it as a component to an object in your scene:https://medium.com/media/38503aacd9179b10cef8e5c9e2aba805/href

1.4.2 Interstitial Advertising Code Integration

Create a new C# script called ReklamInterstitial and give it as a component to an object in your scene. What we will do is this; There will be a button on the screen and when we click on this button, the Interstitial ad will appear on the screen. To do this, change the content of the C# script as follows:https://medium.com/media/2594dfe5fbe61013eebfe673bcb07d44/href

1.4.3 Rewarded Advertising Code Integration

Create a new C# script called ReklamRewardedVideo and give it as a component to an object in your scene. With this script, it will create a button on the screen and when you click on this button, it will play a Rewarded video ad:https://medium.com/media/eb308e6e7cde2d9106aa5a55d987f62b/href

2. Unity Ads Integration for Unity

Thank you for the source I used while writing the article. Click here.

Unity Ads supports 3 types of ads, just like Google Admob. These are Banner, Interstitial and Rewarded ads, as we see in Google Admob.

  • Banner: These are small ads that appear at the top or bottom of the screen throughout the game.
  • Interstitial: These are ads that are full screen and consist of an image or video. If the ad consists of a video, it is possible to skip the ad after watching the video for a few seconds.
  • Rewarded: These are also video ads. Unlike Interstitial, Rewarded ads cannot be skipped, they are watched until the end. But in return, the player receives an in-game reward (reward) is given; for example 50 gold. Showing Rewarded ads but not rewarding the player is against Rewarded advertising policy and may cause ads in your game to stop. Similarly, telling the player that the Rewarded ad will give 50 gold but only giving 10 gold rewards means that the ad is misleading and this may cause the ads to stop. Therefore, in Rewarded advertisements, you should be honest with the player, clearly tell him what the player will earn in return for watching the advertisement, and give that reward to the player when the player watches the advertisement.

2.1 Creating Ads

To create a new ad, we must first create a new project.

For this to this address Go to the Projects tab on the left and click the New Project button. Enter the name of your project in Project Name. You can leave the App Store IDs blank for now. Click the Add Project button to complete the process.

To create an ad, click on the Monetization-Placements tab from the menu on the left on the home page of your project and click on the Add Placement button. Enter a name for the ad in Placement ID and Banner if you are creating a banner ad, Interstitial video if you are creating an Interstitial ad, Rewarded video if you are creating a Rewarded ad. Select the option and click on the Create Placement button to complete the process.

In newly created projects, Unity Ads automatically creates an Interstitial and a Rewarded ad and adds them to them. video gives the names RewardedVideo:

If you wish, you can use them directly instead of creating a new Interstitial or Rewarded ad. My suggestion here is Interstitial (video) click on the ad and click Ad Types Mark everything in it and save the change with the Save button:

The values here are:

  • Video: Video ad that can be skipped after a few seconds
  • Display: Ad consisting of a static image
  • playable: Advertisements where the player can interact with the ad and play the game in the ad directly through the ad.

Finally, you can determine how many seconds it takes for the player to skip the Interstitial ad by changing the value of Allow Skip on the same page:

2.2 Ad Filtering

You can use ad filters to make your ads more appealing to your target audience. To access the filters, follow Monetization-Ad Filters from the menu on the left. As you will see in the incoming window, you can create different filters for Android (Google Play Store) and IOS (Apple App Store). You can apply 2 types of filters to your ads:

  • Category Filtering: It prevents ads from certain categories from appearing in your game.

2.3 Advertising Integration Information

  • Placement IDs of your ad(s): You can learn from the page that appears by clicking on the ad on the Monetization-Placements screen.
  • Game ID: When you switch to the Settings-Project Settings tab on the left, it is located in the Google Play Store (Android) and Apple App Store (IOS) lines, that is, the GAME IDs of the Android and IOS versions of your game are different.

2.4 Integrating Unity Ads into Unity Project

You can add Unity Ads to your project using Package Manager.

2.5 Showing Ads

2.5.1 Banner Ads

Create a C# script and give it as a component to an active Game Object in your scene:

2.5.2 Interstitial Advertisements

Create a C# script and give it as a component to an active Game Object in your scene:

2.5.3 Rewarded Ads

Create a C# script and give it as a component to an active Game Object in your scene:

I hope it helped. Enjoy your work.


en_USEnglish