// Load button
    public void LoadInterstitial ()
    {
        this.statusLabel.text = "Loading interstitial ad...";

        // Create the interstitial unit with a placement ID (generate your own on the Facebook app settings).
        // Use different ID for each ad placement in your app.
        InterstitialAd interstitialAd = new InterstitialAd ("YOUR_PLACEMENT_ID");
        this.interstitialAd = interstitialAd;
        this.interstitialAd.Register (this.gameObject);

        // Set delegates to get notified on changes or when the user interacts with the ad.
        this.interstitialAd.InterstitialAdDidLoad = (delegate() {
            Debug.Log ("Interstitial ad loaded.");
            this.isLoaded = true;
            this.statusLabel.text = "Ad loaded. Click show to present!";
        });
        interstitialAd.InterstitialAdDidFailWithError = (delegate(string error) {
            Debug.Log ("Interstitial ad failed to load with error: " + error);
            this.statusLabel.text = "Interstitial ad failed to load. Check console for details.";
        });
        interstitialAd.InterstitialAdWillLogImpression = (delegate() {
            Debug.Log ("Interstitial ad logged impression.");
        });
        interstitialAd.InterstitialAdDidClick = (delegate() {
            Debug.Log ("Interstitial ad clicked.");
        });

        // Initiate the request to load the ad.
        this.interstitialAd.LoadAd ();
    }
Beispiel #2
0
 public void LoadInterstitial()
 {
     AudienceNetwork.InterstitialAd interstitialAd = this.interstitialAd = new AudienceNetwork.InterstitialAd("177562949545239_177563016211899");
     this.interstitialAd.Register(base.gameObject);
     this.interstitialAd.InterstitialAdDidLoad = delegate
     {
         UnityEngine.Debug.Log("Interstitial ad loaded.");
         isLoaded = true;
     };
     interstitialAd.InterstitialAdDidFailWithError = delegate(string error)
     {
         UnityEngine.Debug.Log("Interstitial ad failed to load with error: " + error);
         RequestInterstitialAds();
     };
     interstitialAd.InterstitialAdWillLogImpression = delegate
     {
         UnityEngine.Debug.Log("Interstitial ad logged impression.");
     };
     interstitialAd.InterstitialAdDidClick = delegate
     {
         UnityEngine.Debug.Log("Interstitial ad clicked.");
     };
     interstitialAd.interstitialAdDidClose = delegate
     {
         UnityEngine.SceneManagement.SceneManager.LoadScene(GameScript.sceneName);
     };
     this.interstitialAd.LoadAd();
 }
Beispiel #3
0
 public void InitFacebookInterstitial()
 {
     if (Application.platform == RuntimePlatform.Android)
     {
         this.interstitialFacebook = new AudienceNetwork.InterstitialAd(FacebookInterstitialID);
         this.interstitialFacebook.Register(this.gameObject);
         LoadInterstitialFacebook();
     }
 }
	public void LoadInterstitial()
	{
		AudienceNetwork.InterstitialAd interstitialAd = this.interstitialAd = new AudienceNetwork.InterstitialAd("177562949545239_319702571997942");
		this.interstitialAd.Register(base.gameObject);
		this.interstitialAd.InterstitialAdDidLoad = delegate
		{
			isLoaded = true;
		};
		interstitialAd.InterstitialAdDidFailWithError = delegate
		{
			if (interstitial == null || !interstitial.IsLoaded())
			{
				RequestInterstitialAds();
			}
		};
		interstitialAd.InterstitialAdWillLogImpression = delegate
		{
		};
		interstitialAd.InterstitialAdDidClick = delegate
		{
		};
		interstitialAd.interstitialAdDidClose = delegate
		{
			if (GameScript.isGameOver)
			{
				gm.retry.SetActive(value: true);
				gm.menu.SetActive(value: true);
				gm.failMenu.SetActive(value: true);
				gm.failRetry.SetActive(value: true);
			}
			if (GameScript.isReplay)
			{
				UnityEngine.SceneManagement.SceneManager.LoadScene(GameScript.sceneName);
			}
		};
		this.interstitialAd.LoadAd();
	}
        #pragma warning restore 0414

        public InterstitialAdBridgeImpressionListenerProxy(InterstitialAd interstitialAd, AndroidJavaObject bridgedInterstitialAd)
            : base("com.facebook.ads.ImpressionListener")
        {
            this.interstitialAd = interstitialAd;
            this.bridgedInterstitialAd = bridgedInterstitialAd;
        }
 internal InterstitialAdContainer (InterstitialAd interstitialAd)
 {
     this.interstitialAd = interstitialAd;
 }
        public override int Create (string placementId,
                                    InterstitialAd interstitialAd)
        {
            int uniqueId = InterstitialAdBridgeIOS.FBInterstitialAdBridgeCreate (placementId);
            InterstitialAdBridgeIOS.interstitialAds.Add (uniqueId, new InterstitialAdContainer(interstitialAd));
            InterstitialAdBridgeIOS.FBInterstitialAdBridgeOnLoad (uniqueId, interstitialAdDidLoadBridgeCallback);
            InterstitialAdBridgeIOS.FBInterstitialAdBridgeOnImpression (uniqueId, interstitialAdWillLogImpressionBridgeCallback);
            InterstitialAdBridgeIOS.FBInterstitialAdBridgeOnClick (uniqueId, interstitialAdDidClickBridgeCallback);
            InterstitialAdBridgeIOS.FBInterstitialAdBridgeOnError (uniqueId, interstitialAdDidFailWithErrorBridgeCallback);
            InterstitialAdBridgeIOS.FBInterstitialAdBridgeOnDidClose (uniqueId, interstitialAdDidCloseBridgeCallback);
            InterstitialAdBridgeIOS.FBInterstitialAdBridgeOnWillClose (uniqueId, interstitialAdWillCloseBridgeCallback);

            return uniqueId;
        }
        public override int Create (string placementId,
                                    InterstitialAd interstitialAd)
        {
            AdUtility.prepare ();
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
            AndroidJavaObject context = currentActivity.Call<AndroidJavaObject>("getApplicationContext");

            AndroidJavaObject bridgedInterstitialAd = new AndroidJavaObject("com.facebook.ads.InterstitialAd", context, placementId);

            InterstitialAdBridgeListenerProxy proxy = new InterstitialAdBridgeListenerProxy (interstitialAd, bridgedInterstitialAd);
            bridgedInterstitialAd.Call ("setAdListener", proxy);

            InterstitialAdBridgeImpressionListenerProxy impressionListenerProxy = new InterstitialAdBridgeImpressionListenerProxy (interstitialAd, bridgedInterstitialAd);
            bridgedInterstitialAd.Call ("setImpressionListener", impressionListenerProxy);

            InterstitialAdContainer interstitialAdContainer = new InterstitialAdContainer (interstitialAd);
            interstitialAdContainer.bridgedInterstitialAd = bridgedInterstitialAd;
            interstitialAdContainer.listenerProxy = proxy;
            interstitialAdContainer.impressionListenerProxy = impressionListenerProxy;

            int key = InterstitialAdBridgeAndroid.lastKey;
            InterstitialAdBridgeAndroid.interstitialAds.Add(key, interstitialAdContainer);
            InterstitialAdBridgeAndroid.lastKey++;
            return key;
        }
 public virtual int Create (string placementId,
                            InterstitialAd InterstitialAd)
 {
     return 123;
 }
Beispiel #10
0
 internal InterstitialAdContainer(InterstitialAd interstitialAd)
 {
     this.interstitialAd = interstitialAd;
 }
Beispiel #11
0
 public virtual int Create(string placementId,
                           InterstitialAd InterstitialAd)
 {
     return(123);
 }
Beispiel #12
0
 public InterstitialAdBridgeListenerProxy(InterstitialAd interstitialAd, AndroidJavaObject bridgedInterstitialAd) : base("com.facebook.ads.InterstitialAdListener")
 {
     this.interstitialAd        = interstitialAd;
     this.bridgedInterstitialAd = bridgedInterstitialAd;
 }