12345678910111213141516171819202122232425262728293031323334 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using GoogleMobileAds.Api;
-
-
-
- public class AdMobManager : MonoBehaviour{
- [SerializeField] GameObject 廣告_pl;
- private BannerView bannerView;
- #if UNITY_ANDROID
- private string _adUnitId = "ca-app-pub-3940256099942544/6300978111";
- #elif UNITY_IPHONE
- private string _adUnitId = "ca-app-pub-3940256099942544/2934735716";
- #else
- private string _adUnitId = "unused";
- #endif
- // Start is called before the first frame update
- void Start(){
- MobileAds.Initialize(initStatus => { });
- this.RequestBanner();
- }
-
-
- private void RequestBanner(){
- // 建立一個橫幅廣告.
- this.bannerView = new BannerView(_adUnitId,AdSize.Leaderboard, AdPosition.BottomLeft);
- // 建立廣告請求.
- AdRequest request = new AdRequest.Builder().Build();
-
- // 載入橫幅廣告.
- this.bannerView.LoadAd(request);
- }
- }
|