Advertisement
onetabgames

Untitled

Jun 24th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using GoogleMobileAds.Api;
  4. using ChartboostSDK;
  5.  
  6. public class AdmobScript : MonoBehaviour
  7. {
  8. public void Start()
  9. {
  10. #if UNITY_ANDROID
  11. string appId = "ca-app-pub-3054887759318215~5075142291";
  12. #elif UNITY_IPHONE
  13. string appId = "ca-app-pub-3054887759318215~7899617738";
  14. #else
  15. string appId = "unexpected_platform";
  16. #endif
  17.  
  18. // Initialize the Google Mobile Ads SDK.
  19. MobileAds.Initialize(appId);
  20. Chartboost.cacheInterstitial(CBLocation.Default);
  21. Chartboost.cacheRewardedVideo(CBLocation.Default);
  22. RequestBanner();
  23. }
  24.  
  25. public void RequestBanner()
  26. {
  27. #if UNITY_EDITOR
  28. string adUnitId = "unused";
  29. #elif UNITY_ANDROID
  30. string adUnitId = "ca-app-pub-3940256099942544/6300978111";
  31. #elif UNITY_IPHONE
  32. string adUnitId = " ca-app-pub-3940256099942544/2934735716";
  33. #else
  34. string adUnitId = "unexpected_platform";
  35. #endif
  36.  
  37. // Create a 320x50 banner at the bottom of the screen.
  38. BannerView bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);
  39. // Create an empty ad request.
  40. AdRequest request = new AdRequest.Builder().Build();
  41. // Load the banner with the request.
  42. bannerView.LoadAd(request);
  43. }
  44. public void showInterstitialAd()
  45. {
  46. if (Chartboost.hasInterstitial(CBLocation.Default))
  47. {
  48. Chartboost.showInterstitial(CBLocation.Default);
  49. }
  50. else
  51. {
  52. Chartboost.cacheInterstitial(CBLocation.Default);
  53. }
  54. }
  55. public void ShowRewardedVideo()
  56. {
  57. if(Chartboost.hasRewardedVideo(CBLocation.Default))
  58. {
  59. Chartboost.showRewardedVideo(CBLocation.Default);
  60. }
  61. else
  62. {
  63. Chartboost.cacheRewardedVideo(CBLocation.Default);
  64. }
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement