Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using GoogleMobileAds.Api;
- using ChartboostSDK;
- public class AdmobScript : MonoBehaviour
- {
- public void Start()
- {
- #if UNITY_ANDROID
- string appId = "ca-app-pub-3054887759318215~5075142291";
- #elif UNITY_IPHONE
- string appId = "ca-app-pub-3054887759318215~7899617738";
- #else
- string appId = "unexpected_platform";
- #endif
- // Initialize the Google Mobile Ads SDK.
- MobileAds.Initialize(appId);
- Chartboost.cacheInterstitial(CBLocation.Default);
- Chartboost.cacheRewardedVideo(CBLocation.Default);
- RequestBanner();
- }
- public void RequestBanner()
- {
- #if UNITY_EDITOR
- string adUnitId = "unused";
- #elif UNITY_ANDROID
- string adUnitId = "ca-app-pub-3940256099942544/6300978111";
- #elif UNITY_IPHONE
- string adUnitId = " ca-app-pub-3940256099942544/2934735716";
- #else
- string adUnitId = "unexpected_platform";
- #endif
- // Create a 320x50 banner at the bottom of the screen.
- BannerView bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);
- // Create an empty ad request.
- AdRequest request = new AdRequest.Builder().Build();
- // Load the banner with the request.
- bannerView.LoadAd(request);
- }
- public void showInterstitialAd()
- {
- if (Chartboost.hasInterstitial(CBLocation.Default))
- {
- Chartboost.showInterstitial(CBLocation.Default);
- }
- else
- {
- Chartboost.cacheInterstitial(CBLocation.Default);
- }
- }
- public void ShowRewardedVideo()
- {
- if(Chartboost.hasRewardedVideo(CBLocation.Default))
- {
- Chartboost.showRewardedVideo(CBLocation.Default);
- }
- else
- {
- Chartboost.cacheRewardedVideo(CBLocation.Default);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement