Zasadniczo próbuję załadować baner reklamowy do mojego projektu Unity 5 i eksportować do iOS.Jak załadować reklamy AdMob do projektu Unity 5?
Oto kod ja dzwonię wnętrza jedności, która jest przymocowana do obiektu gra:
using UnityEngine;
using System.Collections;
using GoogleMobileAds.Api;
using System;
public class AdController : MonoBehaviour {
InterstitialAd interstitial;
BannerView bannerView;
void Start() {
//------ Banner Ad -------
// Create a 320x50 banner at the top of the screen.
// Put your Admob banner ad id here
bannerView = new BannerView(
"ca-app-pub-xxxxxxxxxxxxxxxx", AdSize.SmartBanner, AdPosition.Top);
// Create ad request
AdRequest request = new AdRequest.Builder().Build();
// Load the banner with the request.
bannerView.LoadAd(request);
bannerView.Show();
//---- Interstitial Ad -----
// Initialize an InterstitialAd.
// Put your admob interstitial ad id here:
interstitial = new InterstitialAd("ca-app-pub-xxxxxxxxxxxxxxx");
//Add callback for when ad is loaded
interstitial.AdLoaded += HandleAdLoaded;
// Create an ad request.
AdRequest requestInterstitial = new AdRequest.Builder().Build();
// Load the interstitial with the request.
interstitial.LoadAd(requestInterstitial);
}
public void HandleAdLoaded(object sender, EventArgs args) {
interstitial.Show();
}
void OnDestroy(){
if (interstitial!=null) {
interstitial.AdLoaded -= HandleAdLoaded;
interstitial.Destroy();
}
if(bannerView!=null){
bannerView.Destroy();
}
}
}
Używam:
- Unity 5.0.1f1
- Xcode 6.3
- Wtyczka Google Unity 2.2.1
- Pakiet reklam Google 7.2.1
Czy ktoś ma to do wyświetlania reklam? Uwaga: zastąpiłem xxxxx prawidłowym identyfikatorem jednostki reklamowej.
nadzieję, że to pomaga .. –
http://a2dr.blogspot.in/2015/03/how-to-integrate-admob-into-unity-5-ios_31.html aby uzyskać pomoc .. –
powyższy przykład dotyczy starszej wersji AdMob SDK i starszej wersji Xcode. – loyalpenguin