Quantcast
Channel: Questions in topic: "ads"
Viewing all articles
Browse latest Browse all 1416

How can I get the Interstitials to show

$
0
0
I am trying to show an interstitial ad in my game, but I can't figure out how to do it my script: using UnityEngine; using UnityEngine.Advertisements; using GoogleMobileAds.Api; public class ads : MonoBehaviour { static public bool showInterstitial = false; bool done = false; InterstitialAd ad; //Interstitial ad void Start(){ RequestBanner(); showInterstitial = true; RequestInterstitial(); } private void RequestBanner() { #if UNITY_ANDROID string adUnitId = "ca-app-pub-2298967481644009/6636810571"; #elif UNITY_IPHONE string adUnitId = "ca-app-pub-2298967481644009/6636810571"; #else string adUnitId = "unexpected_platform"; #endif // Create a 320x50 banner at the top of the screen. BannerView bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom); // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the banner with the request. bannerView.LoadAd(request); } void RequestInterstitial() { #if UNITY_ANDROID string adUnitId = "ca-app-pub-2298967481644009/6636810571"; #elif UNITY_IPHONE string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE"; #else string adUnitId = "unexpected_platform"; #endif // Initialize an InterstitialAd. InterstitialAd interstitial = new InterstitialAd (adUnitId); ad = interstitial; // Create an empty ad request. AdRequest request = new AdRequest.Builder ().Build (); // Load the interstitial with the request. interstitial.LoadAd (request); Debug.Log("done"); // Called when an ad request has successfully loaded. interstitial.AdLoaded += HandleAdLoaded; } public void HandleAdLoaded(object sender, EventArgs args) { print("HandleAdLoaded event received."); Interstitial.show (); // Handle the ad loaded event. } I get this error: error CS0246: The type or namespace name `EventArgs' could not be found. Are you missing a using directive or an assembly reference? I have watched some tutorials and examples, but I can't spot what I am doing wrong. the interstitial variable isn't global, so I can't use it outside the function. I have tried, but if you know what I might be doing wrong, please show me :) I have tried to use the ad variable I declared, but when I am trying ad.Show(), I get an error.

Viewing all articles
Browse latest Browse all 1416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>