Source Code:
using UnityEngine;
using UnityEngine.UI;
using GoogleMobileAds.Api;
public class MenampilkanIklan : MonoBehaviour {
public string mobileAppId = "ca-app-pub-3940256099942544~3347511713",
unitBannerId="ca-app-pub-3940256099942544/6300978111",
idintertial="ca-app-pub-6567675884089961/7662604544";
private BannerView banner;
private InterstitialAd inter;
public Button btnIntertial;
// Use this for initialization
void Start () {
MobileAds.Initialize (mobileAppId);
banner = new BannerView (unitBannerId, AdSize.Banner, AdPosition.Top);
AdRequest req = new AdRequest.Builder ().Build ();
banner.LoadAd (req);
inter = new InterstitialAd(idintertial);
inter.LoadAd (new AdRequest.Builder ().Build ());
}
public void butnIntertial(){
if (inter.IsLoaded()) {
inter.Show ();
}
}
void Update(){
if (inter.IsLoaded()) {
btnIntertial.GetComponentsInChildren<Text> () [0].text = "adReady";
} else {
btnIntertial.GetComponentsInChildren<Text> () [0].text = "LoadAd.....";
inter.LoadAd (new AdRequest.Builder ().Build ());
}
}
}
using UnityEngine.UI;
using GoogleMobileAds.Api;
public class MenampilkanIklan : MonoBehaviour {
public string mobileAppId = "ca-app-pub-3940256099942544~3347511713",
unitBannerId="ca-app-pub-3940256099942544/6300978111",
idintertial="ca-app-pub-6567675884089961/7662604544";
private BannerView banner;
private InterstitialAd inter;
public Button btnIntertial;
// Use this for initialization
void Start () {
MobileAds.Initialize (mobileAppId);
banner = new BannerView (unitBannerId, AdSize.Banner, AdPosition.Top);
AdRequest req = new AdRequest.Builder ().Build ();
banner.LoadAd (req);
inter = new InterstitialAd(idintertial);
inter.LoadAd (new AdRequest.Builder ().Build ());
}
public void butnIntertial(){
if (inter.IsLoaded()) {
inter.Show ();
}
}
void Update(){
if (inter.IsLoaded()) {
btnIntertial.GetComponentsInChildren<Text> () [0].text = "adReady";
} else {
btnIntertial.GetComponentsInChildren<Text> () [0].text = "LoadAd.....";
inter.LoadAd (new AdRequest.Builder ().Build ());
}
}
}
Oke semoga bermanfaat dan membantu
0 Response to "Cara Menampilkan Banner Iklan Admob Pada Game Android (Unity 3d)"
Posting Komentar