Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.
- using System;
- using UnityEngine;
- #if UNITY_ANDROID
- namespace HutongGames.PlayMaker.Actions
- {
- [ActionCategory("AdMob")]
- [Tooltip("Displays a banner Ad - Android Only")]
- public class ShowInterstitial : FsmStateAction
- {
- [Tooltip("Would you like this banner at the top of your sceen or the bottom.")]
- public FsmString interstitialAdID;
- #if !UNITY_EDITOR
- private AdMobPlugin adMobPlugin_;
- #endif
- public override void OnEnter()
- {
- #if !UNITY_EDITOR
- string adID = AdMobHelper.GetInstance.GetID();
- try {
- AdMobPlugin.InterstitialLoaded += HandleInterstitialLoaded;
- GameObject go = GameObject.Find ("AdMob Android");
- if(go) {
- adMobPlugin_ = (AdMobPlugin)go.GetComponent("AdMobPlugin") as AdMobPlugin;
- adMobPlugin_.CreateBanner(adID, AdMobPlugin.AdSize.LEADERBOARD, true, interstitialAdID.Value);
- adMobPlugin_.RequestInterstitial();
- }
- else {
- Debug.LogError("Put the AdMob Android prefab in your scene");
- Finish();
- }
- }
- catch(Exception e) {
- Debug.LogError(e.ToString());
- Finish();
- }
- #else
- Finish();
- #endif
- }
- #if !UNITY_EDITOR
- public override void OnExit ()
- {
- AdMobPlugin.InterstitialLoaded -= HandleInterstitialLoaded;
- }
- void HandleInterstitialLoaded() {
- adMobPlugin_.ShowInterstitial();
- Finish();
- }
- #endif
- }
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement