123456789101112131415161718192021222324252627282930313233343536 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using GoogleMobileAds.Api;
- using System;
-
-
-
- public class AdMobManager : MonoBehaviour{
- [SerializeField] GameObject 廣告_pl;
- private BannerView bannerView;
- #if UNITY_ANDROID
- //private string _adUnitId = "ca-app-pub-3940256099942544/6300978111";
- private string _adUnitId = "ca-app-pub-3570555734266765/5732940619";
- #elif UNITY_IPHONE
- //private string _adUnitId = "ca-app-pub-3940256099942544/2934735716";
- private string _adUnitId = "ca-app-pub-3570555734266765/6059409528";
- #else
- private string _adUnitId = "unused";
- #endif
- // Start is called before the first frame update
- void Start(){
- MobileAds.Initialize(initStatus => { });
- }
-
- public void RequestBanner(){
- bannerView?.Destroy();
- this.bannerView = new BannerView(_adUnitId,AdSize.Leaderboard, AdPosition.BottomLeft);
- AdRequest request = new();
- this.bannerView.LoadAd(request);
- }
- public void HideBanner(){
- bannerView?.Destroy();
- }
-
- }
|