Okay I've tried for three days to write a custom action to use with Playmaker that specifically works with Admob. I've already signed up and set up all the my ads, though Google states clearly not to use real ads for testing, so I've used the dummy adUnitIds provided by Google and installed the Mobileads plugin. To preface, I'm not a programmer, so I have no ideas why it won't work. For example, I've been trying to write an action for banner ads. Here's the most recent:
using UnityEngine;
using System;
using GoogleMobileAds;
using GoogleMobileAds.Api;
using GoogleMobileAds.Common;
namespace HutongGames.Playmaker.Actions
[ActionCategory("Admob")]
public class ShowBanner : FsmStateAction
{
private BannerView bannerView;
public static ShowBanner current;
void Start()
{
current = this;
RequestBanner();
this.bannerView.Show();
public void RequestBanner()
{
#if UNITY_EDITOR
string adUnitId = "unused";
#elif UNITY_ANDROID
string adUnitId = "ca-app-pub-xxxxxxxxxxx/xxxxxxxxx";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-xxxxxxxxxxx/xxxxxxxxx";
#else
string adUnitId = "unexpected_platform";
bannerView = new BannerView(adUnitId, Adsize.SmartBanner, Adposition.Bottom);
bannerView.OnAdLoaded += HandleOnAdLoaded;
bannerView. OnAdFailedToLoad += HandleAdFailedToLoad;
bannerView. OnAdOpening += HandleOnAdOpening;
bannerView. OnAdClosed += HandleOnAdClosed;
bannerView. OnAdLeavingApplication += HandleOnAdLeavingApplication
bannerView. LoadAd(createAdRequest));
}
private Adrequest createAdRequest()
{
return new Adrequest.Builder()
.AddTestDevice(Adrequest.TestDeviceSimulator)
.AddTestDevice("123456789ABCDEF")
.AddKeyword("game")
.SetGender(Gender. " " )
.SetBirthday(1981, 7, 8
.TagForChildDirectiveTreatmenyt(false)
.AddExtra("color_bg, 9B30FF")
.Build();
}
#region Banner callbacks hander's
public void HandleOnAdLoaded(object senders, EventArgs args)
{
Monobehaviour. print("HandleOnAdLoaded");
}
public void HandleAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
Monobehaviour.print("HandleFailedToReceiveAd event received with message: " + args);
public void HandleOnAdOpening(object senders, EventArgs args)
{
Monobehaviour. print("HandleOnAdOpening");
}
public void HandleOnAdClosing(object senders, EventArgs args)
{
Monobehaviour. print("HandleOnAdClosing");
}
public void HandleOnLeavingApplication(object senders, EventArgs args)
{
Monobehaviour. print("HandleOnLeavingApplication
");
}
#endregion
}
}
I was trying to write actions for Interstitial and RewardAds but same outcome. I must've watched eight tutorials for this problem, but I'm stuck. The ads aren't showing up in the Editor or the Build, which means unlikely to play ads even with a published build. Any advice?