Няма описание
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using GoogleMobileAds.Api;
  5. public class AdMobManager : MonoBehaviour{
  6. [SerializeField] GameObject 廣告_pl;
  7. private BannerView bannerView;
  8. #if UNITY_ANDROID
  9. private string _adUnitId = "ca-app-pub-3940256099942544/6300978111";
  10. #elif UNITY_IPHONE
  11. private string _adUnitId = "ca-app-pub-3940256099942544/2934735716";
  12. #else
  13. private string _adUnitId = "unused";
  14. #endif
  15. // Start is called before the first frame update
  16. void Start(){
  17. MobileAds.Initialize(initStatus => { });
  18. this.RequestBanner();
  19. }
  20. private void RequestBanner(){
  21. // 建立一個橫幅廣告.
  22. this.bannerView = new BannerView(_adUnitId,AdSize.Leaderboard, AdPosition.BottomLeft);
  23. // 建立廣告請求.
  24. AdRequest request = new AdRequest.Builder().Build();
  25. // 載入橫幅廣告.
  26. this.bannerView.LoadAd(request);
  27. }
  28. }