Hi,
The google dev site makes implementing ads into your game look easy, but for some weird reason I can’t get them to work, no matter what I try, I guess I’m dumb or something.
Right so here’s what I did, Downloaded the latest GoogleMobileAds.unitypackage and imported it into untiy then I slapped this code(below) to a script and slapped the script to a gameobject.
The gameobject was slapped into existence from inside of the heirarchy panel.
using GoogleMobileAds.Api;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AdsScript : MonoBehaviour {
// Use this for initialization
void Start () {
showBannerAd();
}
private void showBannerAd()
{
string adID = "NOT_SURE_IF_I_SHOULD_SHOW_YOU_GUYS_MY_AD_ID";
//For testing
AdRequest request = new AdRequest.Builder()
.AddTestDevice(AdRequest.TestDeviceSimulator) // Simulator.
.AddTestDevice("2077ef9a63d2b398840261c8221a0c9b") // My test device.
.Build();
//For production
//AdRequest request = new AdRequest.Builder().Build();
BannerView bannerAd = new BannerView(adID, AdSize.SmartBanner, AdPosition.Top);
bannerAd.LoadAd(request);
}
// Update is called once per frame
void Update () {
}
}
I’ve tried running it on my phone, a program called nox on my mac and the unity player(not sure if its called the unity player, but it runs your game when you press “Build and Run”).
So please, could someone guide me, it’ll be vvvveeerrrrrryyyy helpful.
Thanks.