Hello, I’m troubling with the same problems as mentioned above. Please take a closer look to code as follow:
public void ConfirmGameOver()
{
AdManager.instance.ShowFullScreenAd(); here the error of mono behaviour pops up but why?
//activated when replay button is hit
OnGameOverConfirmed(); //event is sent to TapController
scoreText.text = “0”;
SetPageState(PageState.Start);
AdManager.instance.HideBanner();
}
public void StartGame()
{
//activated when play button is hit
SetPageState(PageState.Countdown);
TapController.Instance.StartScript(); //needs to start player after play
AdManager.instance.RequestBanner();
Second error exist to my AdManager Script:
public void RequestFullScreenAd()
{
this.fullScreenAd = new InterstitialAd(fullScreenAdID);
this.fullScreenAd.OnAdLoaded += this.HandleOnAdLoaded;
// called when an ad request failed to load
this.fullScreenAd.OnAdFailedToLoad += this.HandleOnAdFailedToLoad;
// called when an ad is clicked
this.fullScreenAd.OnAdOpening += this.HandleOnAdOpened;
// called when the user returned from the app after an ad click
this.fullScreenAd.OnAdClosed += this.HandleOnAdClosed;
// called when the ad click caused the user to leave the application
this.fullScreenAd.OnAdLeavingApplication += this.HandleOnAdLeavingApplication;
AdRequest request = new AdRequest.Builder().Build();
this.fullScreenAd.LoadAd(request);
}
public void ShowInterstitial()
{
if (this.fullScreenAd.IsLoaded())
{
this.fullScreenAd.Show();
}
else
{
Debug.Log(“Ad not loaded”);
}
}
//events below
public void HandleOnAdLoaded(object sender, EventArgs args)
{
// do this when ad loads
Debug.Log(“Ad Loaed”);
}
public void HandleOnAdFailedToLoad(object sender, EventArgs args)
{
// do this when ad fails to load
Debug.Log(“couldn’t load ad”);
}
public void HandleOnAdOpened(object sender, EventArgs args)
{
// do this when ad is opened
MonoBehaviour.print(“HandleAdOpened event received”);
}
public void HandleOnAdClosed(object sender, EventArgs args)
{
// do this when ad is closed
Debug.Log(“Ad Closed”);
RequestFullScreenAd(); // Optional: in case you want to load another interstitial ad rightaway
}
public void HandleOnAdLeavingApplication(object sender, EventArgs args)
{
//do this when on leaving Application
MonoBehaviour.print(“HandleOnAdLeavingApplication event received”);
}
public void ShowFullScreenAd()
{
if (fullScreenAd.IsLoaded())
{
fullScreenAd.Show();
}
else
Im glad to hear from you guys. Please support. Thanks in advance