摘要:Unity Android Ads Setting(AdMob)
Step1:
download unity package(GoogleMobileAds.unitypackage) and source code(googleads-mobile-plugins-2.1.zip)
https://github.com/googleads/googleads-mobile-plugins/releases
Step2:
register a Acccount
http://www.google.com/ads/admob/?_adc=ww-en-et-developers_sdk
Select yput app and set the ads names
Setting two ad unit and you can see the Ad unity IDs
Step3:
create a new unity project called New Unity Project AdsTest in E:\My Documents\New Unity Project AdsTest(for example)
import GoogleMobileAds.unitypackage(drag to unity editor)
Step4:
Run SDK Manager.exe to get Google Play Services
Copy C:\adt-bundle-windows-x86-20140702\sdk\extras\google\google_play_services\libproject\google-play-services_lib\libs\google-play-services.jar to Unity Project \ Assets \ Plugins \ Android
Step5:
unzip googleads-mobile-plugins-2.1.zip and copy unity\samples\HelloWorld\Assets
GoogleMobileAdsDemoScript.cs
MainScene.unity
to Unity Project \ Assets
Step6:
Open GoogleMobileAdsDemoScript.cs and fill the ad unit id
private void RequestBanner()
{
#if UNITY_EDITOR
string adUnitId = "unused";
#elif UNITY_ANDROID
string adUnitId = "INSERT_ANDROID_BANNER_AD_UNIT_ID_HERE";
#elif UNITY_IPHONE
string adUnitId = "INSERT_IOS_BANNER_AD_UNIT_ID_HERE";
#else
string adUnitId = "unexpected_platform";
#endif
private void RequestInterstitial()
{
#if UNITY_EDITOR
string adUnitId = "unused";
#elif UNITY_ANDROID
string adUnitId = "INSERT_ANDROID_INTERSTITIAL_AD_UNIT_ID_HERE";
#elif UNITY_IPHONE
string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE";
#else
string adUnitId = "unexpected_platform";
#endif
Step7:
Add res/values directory under Assets\Plugins\Android
create a xml called version.xml under the values diectory
the version .xml content as below
<?xml version="1.0" encoding="UTF-8"?>
-<resources>
<integer name="google_play_services_version">6111000</integer>
</resources>
Step8:
Setting Bundle Identifier and Project Name in Android Setting UI
Step9:
drag the MainScene to Build Setting window and then switch to Android and "Run Adn Run"
PS:assign GoogleMobileAdsDemoScript.cs to MainScene if the link loses
Step10:
click "Request Banner" and then click "Show Banner", you can see the ads banner at top
See also:
How to Integrate Admob with Unity for Android - Tutorial