Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- #if USE_ADMOB
- using GoogleMobileAds.Api;
- #endif
- public class Adbanner : MonoBehaviour {
- private BannerView bannerView;
- public void Start()
- {
- #if USE_ADMOB
- #if UNITY_ANDROID
- string appId = "ca-app-pub-3983044154532971~2164382138";
- #elif UNITY_IPHONE
- string appId = "ca-app-pub-3983044154532971~2164382138";
- #else
- string appId = "unexpected_platform";
- #endif
- // Initialize the Google Mobile Ads SDK.
- MobileAds.Initialize(appId);
- this.RequestBanner();
- }
- internal bool NPA;
- internal TestMethod TestMode = TestMethod.DisableTestMode;
- internal static Adbanner instance;
- private void Awake()
- {
- if (instance == null)
- instance = this;
- }
- private void RequestBanner()
- {
- #if UNITY_ANDROID
- string adUnitId = "ca-app-pub-3940256099942544/6300978111";
- #elif UNITY_IPHONE
- string adUnitId = "ca-app-pub-3940256099942544/6300978111";
- #else
- string adUnitId = "unexpected_platform";
- #endif
- AdRequest request;
- // Create an ad request.
- if (NPA)
- request = new AdRequest.Builder().AddTestDevice(AdRequest.TestDeviceSimulator).AddExtra("npa", "1").Build();
- else
- request = new AdRequest.Builder().AddTestDevice(AdRequest.TestDeviceSimulator).Build();
- BannerView bannerAd = new BannerView(adUnitId, AdSize.SmartBanner, AdPosition.Bottom);
- bannerAd.LoadAd(request);
- }
- #endif
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement