Advertisement
Guest User

Untitled

a guest
Aug 10th, 2015
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.67 KB | None | 0 0
  1. using UnityEngine;
  2. using com.amazon.mas.cpt.ads;
  3.  
  4. public class AmazonAdsTest : MonoBehaviour {
  5.  
  6.     IAmazonMobileAds mobileAds;
  7.     Ad mobileAd;
  8.  
  9.     void Start () {
  10.         mobileAds = AmazonMobileAdsImpl.Instance;
  11.     }
  12.    
  13.     void OnGUI () {
  14.         if (GUILayout.Button("Init", GUILayout.Width(200f), GUILayout.Height(100f))) {
  15.  
  16.             ShouldEnable enable = new ShouldEnable();
  17.             enable.BooleanValue = true;
  18.             mobileAds.EnableLogging(enable);
  19.             mobileAds.EnableTesting(enable);
  20.             mobileAds.EnableGeoLocation(enable);
  21.  
  22.             ApplicationKey key = new ApplicationKey();
  23.             key.StringValue = "sample-app-v1_pub-2";
  24.             mobileAds.SetApplicationKey(key);
  25.         }
  26.  
  27.         if (GUILayout.Button("CreateInterstitialAd", GUILayout.Width(200f), GUILayout.Height(100f))) {
  28.             mobileAd = mobileAds.CreateInterstitialAd();
  29.             // Get return values
  30.             string adType = mobileAd.AdType.ToString();
  31.             long identifier = mobileAd.Identifier;
  32.             Debug.Log( adType + "    " + identifier );
  33.         }
  34.  
  35.         if (GUILayout.Button("LoadInterstitialAd", GUILayout.Width(200f), GUILayout.Height(100f))) {
  36.             LoadingStarted response = mobileAds.LoadInterstitialAd();
  37.             bool loadingStarted = response.BooleanValue;
  38.             Debug.Log("loadingStarted: " + loadingStarted);
  39.         }
  40.  
  41.         if (GUILayout.Button("Play", GUILayout.Width(200f), GUILayout.Height(100f))) {
  42.  
  43.             AdShown response = mobileAds.ShowInterstitialAd();
  44.             bool adShown = response.BooleanValue;
  45.             Debug.Log("adShown: " + adShown);
  46.         }
  47.     }
  48.    
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement