Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. #if USE_ADMOB
  5. using GoogleMobileAds.Api;
  6. #endif
  7.  
  8.  
  9.  
  10.  
  11. public class Adbanner : MonoBehaviour {
  12.  
  13.  
  14.  
  15. private BannerView bannerView;
  16.  
  17. public void Start()
  18. {
  19. #if USE_ADMOB
  20. #if UNITY_ANDROID
  21. string appId = "ca-app-pub-3983044154532971~2164382138";
  22. #elif UNITY_IPHONE
  23. string appId = "ca-app-pub-3983044154532971~2164382138";
  24. #else
  25. string appId = "unexpected_platform";
  26. #endif
  27.  
  28. // Initialize the Google Mobile Ads SDK.
  29. MobileAds.Initialize(appId);
  30.  
  31. this.RequestBanner();
  32. }
  33.  
  34. internal bool NPA;
  35.  
  36. internal TestMethod TestMode = TestMethod.DisableTestMode;
  37.  
  38. internal static Adbanner instance;
  39.  
  40. private void Awake()
  41. {
  42. if (instance == null)
  43. instance = this;
  44. }
  45.  
  46.  
  47.  
  48. private void RequestBanner()
  49. {
  50. #if UNITY_ANDROID
  51. string adUnitId = "ca-app-pub-3940256099942544/6300978111";
  52. #elif UNITY_IPHONE
  53. string adUnitId = "ca-app-pub-3940256099942544/6300978111";
  54. #else
  55. string adUnitId = "unexpected_platform";
  56. #endif
  57.  
  58.  
  59.  
  60.  
  61. AdRequest request;
  62.  
  63. // Create an ad request.
  64. if (NPA)
  65. request = new AdRequest.Builder().AddTestDevice(AdRequest.TestDeviceSimulator).AddExtra("npa", "1").Build();
  66. else
  67. request = new AdRequest.Builder().AddTestDevice(AdRequest.TestDeviceSimulator).Build();
  68.  
  69. BannerView bannerAd = new BannerView(adUnitId, AdSize.SmartBanner, AdPosition.Bottom);
  70. bannerAd.LoadAd(request);
  71. }
  72. #endif
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement