暫無描述
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.

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