Introduction to Admob Unity Advertising Plugin Project, Unity Development Profit Ideas

Introduction to Admob Unity Plugin

Admob Unity Plugin provides a way to integrate admob advertising into Unity3D Game and u3d applications.You can use it for Unity iOS and Android App with the same c# or js code.

Is Unity3d's Admob SDK plug-in, which makes it easier for js and c# developers to add Google ads to Unity3d games, support iOS and Android, support admob paged ads and banners

Admob Unity Plugin Description

The Google Mobile Advertising SDK is the latest generation of Google mobile advertising products, with a complete advertising format and simplified API, and access to mobile advertising networks and advertising solutions.The SDK enables Unity mobile application developers to maximize the benefits of native mobile applications.

The repository contains the source code for the Google Mobile Ads Unity plug-in.This plug-in makes it easy for Unity developers to put Google mobile ads on Android and iOS applications without writing Java or Objective-C code.The plug-in provides a C# interface for requesting advertisements for use by C# scripts in Unity projects.

Unity Admob Plugin Function

A platform supported by plug-ins:

  • Android, via SDK v18.3.0 (part of the Google Play service platform)

  • iOS, via SDK v7.53

  • Supports all local events

  • AdRequest positioning methods, such as child positioning, test mode

  • You do not need to change the Android package name

  • Very simple API

  • Support non-personalized advertising

Advertising type:

  • Slogan (all slogan types and custom slogan sizes)

  • Inserted ads (text, pictures, video)

  • Reward Video

  • Advanced Native Advertising

Download Admob Unity Plugin

AdmobPluginRes / GoogleMobileAds.framework and admob_unity_plugin.unitypackage are required.please
From Admob Unity3d Plugin Project Home Page Download these files,
Or Download all Unity's admob plug-in projects /unity-plugins/Unity-Admob/archive/

Install Admob Unity

  1. Open your project in the Unity editor.

  2. Navigate to Assets-> Import Package-> Custom Package.

  3. Select the admob_unity_plugin.unitypackage file.

  4. Import all files except admobdemo.cs (sample script) by selecting Import.Make sure to check for any conflicts with the file.

You can install and copy files from the folder plugin directly into the Unity3d project by downloading files.

Unity Plugin Wiki and Documentation

Quick Start

Edit AndroidManifest.xml and configure Admob APP ID

admob has required this configuration since version 17.0 and if not, APP will crash.Add a metadata tag to the application and set the value to admob appid

 <meta-data android:name="" android:value="ca-app-pub-xxxxxxxxxxxxxxxxxx~xxxxxxxxxxxx"/>

Sample Code

 <application android:theme="@style/UnityThemeSelector" android:icon="@drawable/app_icon" android:label="@string/app_name" > <activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <meta-data android:name="" android:value="ca-app-pub-3940256099942544~3347511713"/> </application>

Edit Info.plist, add appid

<key>GADApplicationIdentifier</key> <string>ca-app-pub-xxxxxxxxxxxxxxxxxxxxxx~xxxxxxxxxxxxxx</string>

Configure the exported Xcode project, build settings - > other linker flags, add flags - ObjC

1.Init Admob Unity Plugin

Create an AC script, drag it onto objects in the scene, and add the following code to the script file

using admob; Admob.Instance().initSDK(new AdProperties());//admob id configed in meta,not support in code any more

You can set the admob property as follows, you need to set the property to set

 AdProperties adProperties = new AdProperties(); adProperties.isTesting(true);//true for test ads adProperties.isAppMuted(true); adProperties.isUnderAgeOfConsent(false); adProperties.appVolume(100); adProperties.maxAdContentRating(AdProperties.maxAdContentRating_G); string[] keywords = { "key1", "key2", "key3" }; adProperties.keyworks(keywords);

2. Add Admob Banner to Unity App

This is the minimum code required to display admob slogans.

Admob.Instance().showBannerRelative("your admob banner unit id",AdSize.BANNER, AdPosition.BOTTOM_CENTER, 0);

Or you can create another banner by setting its name

Admob.Instance().showBannerAbsolute("ca-app-pub-3940256099942544/6300978111",AdSize.BANNER, 20, 220,"mybanner");

The AdPosition class specifies where to place the banner.AdSize Specifies Witch Size Banner to Display

3. Delete Banner

By default, the banner is visible.To hide the banner, please call:


4. How do I integrate non-in-page ads into Unity 3d apps?

This is the minimum code to create an inset ad.

Admob.Instance().loadInterstitial("Your admob interstitial unit id");

Unlike banner ads, inserted ads need to be clearly displayed.At the appropriate stop point for the application, check that it is ready before displaying the inset advertisement:

if (Admob.Instance().isInterstitialReady()) { Admob.Instance().showInterstitial(); }

5, Customize Admob Slogan Advertising Size

In addition to the constants on AdSize, you can create custom sizes:

//Create a 250x250 banner. AdSize adSize = new AdSize(250, 250); Admob.Instance().showBannerAbsolute("Your admob banner id",adSize,0,30,"bannerName");

6. How do I integrate Admob reward videos into the Unity3d app?

This is the minimum code to create an admob video.


Videos like plug-in videos need to be clearly displayed at the appropriate stop point in your application. Check that the video is ready before displaying it:

if (Admob.Instance().isRewardedVideoReady()) { Admob.Instance().showRewardedVideo(); }

7. Display native premium Admob ads on iOS and Android App

This is the minimum code required to display AdMob slogans.This is achieved through Admob's native Advertising Premium (Unified)

Admob.Instance().showNativeBannerRelative("Your native banner id",new AdSize(360,100), AdPosition.BOTTOM_CENTER);

8. Advertising Activities

These two banners and interstitial features contain the same advertising campaigns that you can register for.Here, we will show you how to set up an ad event on an Inserted Advertisement and display the Inserted Advertisement when the load is successful:

Admob.Instance().interstitialEventHandler += onInterstitialEvent; void onInterstitialEvent(string eventName, string msg) { Debug.Log("handler onAdmobEvent---" + eventName + " " + msg); if (eventName == AdmobEvent.onAdLoaded) { Admob.Instance().showInterstitial(); } }

You just need to register for events that matter to you.

Unity Admob Demonstration Usage

  1. Import AdmobUnityPlugin.unitypackage into your Unity project

  2. Copy Admobdemo.cs from AdmobPluginRes to your Unified Project/Asset dic

  3. Attach admobdemo.cs to the main camera

  4. Edit admob ID in admobdemo.cs

  5. Build and run on your device

  6. Add-ObjC flag to xcode Other linker flag 7 Add meta application key to Xcode Info.plist

    GADApplicationIdentifier ca-app-pub-xxxxxxxxxxxxxxxxxx〜xxxxxxxxxx

Important Tips

  1. If you do not configure AndroidManifest.xml, the application will crash

  2. If the -ObjC flag is not added, the application will crash

  3. If you do not add GADApplicationIdentifier to Info.plist, the application will crash

  4. Attach admob to an object in the scene and initialize admob before calling admob fun


Tags: Mobile Unity Android Google

Posted on Tue, 17 Mar 2020 13:17:28 -0400 by shoebappa