QUICK TIP - Instructions to integrate Admob ads into Unity games

0 1,794

1. Introduction

img_5f155f9459343 | A&H Business Technology
Related posts

Hi everyone, today I am going to show you how to make a new game unity using Google Admob ads in your games. I see there are some articles on the internet, but they are not very specific, so I will try to write very detailed and easy to understand.

The reason why you should use Admob ads is, in my opinion, an ad from Google, so it is very secure in terms of revenue: the impression share and high CPM can say it is the top in the ad networks. . The other reason is that it is very light and runs smoothly without jerking your game. One thing to note when using this guy is that you must read the rules carefully so as not to violate because they do it very strictly.

2. Instructions

Ok now let me start the tutorial. First, you need to download the GoogleMobileAds.unitypackage asset package on its homepage: https://github.com/googleads/googleads-mobile-unity/releases note that download the latest one that is used – the current version is 3.2 .0. Next, import the downloaded package into your game.


now you see in the Assets folder there are more items as follows:

Next you create yourself an Admob account and create advertising ids for your game, if you do not know then refer to the following instructions: https://www.youtube.com/watch?v=CUidLrFqk6Y please Create a banner ad id into a full screen advertising id to test offline. Ok, now we will write code. You create a file ShowAdsManager.cs script and content as below


You enter your corresponding ids in the id variables at the top, the testDeviceId is the test id of the device you use to test, it’s quite important because otherwise you will show real ads and if you miss manually clicking it will violate the policy, we should only show test ads during development when uploading to the store to show ads. You can find this id for android here: https://play.google.com/store/apps/details?id=pe.go_com.admobdeviceidfinder for ios then follow this: http://stackoverflow.com / questions / 24760150 / how-to-get-a-hashed-device-id-for-testing-admob-on-ios http://answers.unity3d.com/questions/834119/admob-device-id-on- ios-for-test-ads.html

Ok let me explain through the above code, but read that you already know what it is for:

  • LoadFullAdmob this function to load a full screen ad, want to show full screen ads must call this function first
  • ShowFullAdmod this function to display the ad full screen and will load a new one so that the next time it will show up
  • LoadBannerAdmod this function to load a banner here is the banner at the bottom of the screen
  • ShowBanner banner display function
  • HideBanner hides the banner function

Ok, it looks good, nothing is very simple

Now create an interface for testing. Create the screen as follows:

Next create an object named AdsManager and add the above script to it.

Enter your corresponding advertising ids

Next add button click events to the buttons

Ok almost finished setup, save the scene and build it to test. To build for Android, you switch the platform to Android and build the apk file and test.

But for iOS, you need to take one more step is to add its framework to the Xcode project. After building the Xcode project, open it.

Next download the framework on its homepage: https://firebase.google.com/docs/admob/ios/download you will see in the download file that has a file, GoogleMobileAds.framework, copy it to the frameworkds directory of project xcode, then go to Build Phases and drag GoogleMobileAds.framework here

ok now build and test

Here I completed the tutorial, if you have any questions, please feel free to ask me, I will enthusiastically answer.

TinyURL for this post: https://tinyurl.com/y3wu4rlf

Sorry, The Comment Form Is Temporarily Closed At This Time
You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More