[Admob] Interstitial script The type `InterstitialAd' does not contain a constructor
Hello everyone, how are you? I'm fine. I'm trying to write the scripts for monetizate my game with Google AdMob. I have to make two scripts, one for my BannerAd and the second for the interstitial.
This is my script for interstitialAd. I have written the code that loads and shows the ad. using System.Collections; using System.Collections.Generic; using UnityEngine; using GoogleMobileAds.Api;
public class InterstitialAd : MonoBehaviour {
private InterstitialAd interstitial;
private void requestInterstitial() {
//Los siguientes adUnitId son anuncios de prueba, antes de publicarlo debo reemplazar adUnitId con el id del bloque de anuncios
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-3940256099942544/1033173712";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-3940256099942544/4411468910";
#else
string adUnitId = "unexpected_platform";
#endif
// Initialize an InterstitialAd. //Id Del bloque de anuncios
this.interstitial = new InterstitialAd("ca-app-pub-3940256099942544/1033173712");
// Use this for initialization
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
//Load the interstitial with the request interstitial
this.interstitial.LoadAd(request);
}
//ShowAd
private void showInterstitial() {
if (Time.time % 45 == 0 && Time.timeSinceLevelLoad > 60 && this.interstitial.IsLoaded()) {
this.interstitial.Show();
}
}
}
But I have an error that says
Assets/Scripts/InterstitialAd.cs(20,25): error CS1729: The type InterstitialAd' does not contain a constructor that takes
1' arguments
Assets/Scripts/InterstitialAd.cs(25,24): error CS1061: Type InterstitialAd' does not contain a definition for
LoadAd' and no extension method LoadAd' of type
InterstitialAd' could be found. Are you missing an assembly reference?
Assets/Scripts/InterstitialAd.cs(30,79): error CS1061: Type InterstitialAd' does not contain a definition for
IsLoaded' and no extension method IsLoaded' of type
InterstitialAd' could be found. Are you missing an assembly reference?
Assets/Scripts/InterstitialAd.cs(31,23): error CS1061: Type InterstitialAd' does not contain a definition for
Show' and no extension method Show' of type
InterstitialAd' could be found. Are you missing an assembly reference?
Hope you can help me ! Thanks, Mauro
Answer by maurostancato · Mar 31, 2019 at 06:16 PM
I continue with the problem.. Hope someone can help me ! Thanks, from Argentina.
Your answer
Follow this Question
Related Questions
How do you copy an image from the clipboard into an ui image? 0 Answers
How to display ads every 5 mins ? 1 Answer
Problem with Score/Highscore script 0 Answers
Enable Unity Ads in Services 0 Answers