AdwareRequest.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using UnityEngine;
  2. public class AdwareRequest : MonoBehaviour
  3. {
  4. public static bool HasAdware { get; private set; }
  5. #if UNITY_ANDROID
  6. const string BannerAdUnitId = "1a553046db6a4cb2816f1f837c79fa19";
  7. #endif
  8. #if UNITY_IPHONE
  9. const string BannerAdUnitId = "134c4c4a1a3f4522b01eecb07cc5e82c";
  10. //[SerializeField]
  11. // private MoPubManager _manager;
  12. #endif
  13. internal void Start()
  14. {
  15. #if UNITY_ANDROID
  16. //MoPubAndroidManager.onInterstitialLoadedEvent += OnDone;
  17. // MoPubAndroidManager.onInterstitialFailedEvent += OnFail;
  18. // MoPubAndroid.requestInterstitalAd(BannerAdUnitId);
  19. #endif
  20. #if UNITY_IPHONE
  21. // MoPubManager.interstitialDidLoadAdEvent += OnDone;
  22. // MoPubManager.interstitialDidFailToLoadAdEvent += OnFail;
  23. //MoPubManager.interstitialDidDismissEvent += OnDismiss;
  24. // MoPubBinding.requestInterstitialAd(BannerAdUnitId, null);
  25. #endif
  26. }
  27. private void OnFail()
  28. {
  29. #if UNITY_ANDROID
  30. // MoPubAndroid.requestInterstitalAd(BannerAdUnitId);
  31. #endif
  32. #if UNITY_IPHONE
  33. //MoPubBinding.requestInterstitialAd(BannerAdUnitId,null);
  34. #endif
  35. }
  36. private void OnDone()
  37. {
  38. HasAdware = true;
  39. }
  40. #if UNITY_IPHONE
  41. private void OnDismiss()
  42. {
  43. //MoPubBinding.requestInterstitialAd(BannerAdUnitId, null);
  44. }
  45. #endif
  46. public static void Show()
  47. {
  48. if (HasAdware)
  49. {
  50. #if UNITY_ANDROID
  51. //MoPubAndroid.showInterstitalAd();
  52. #endif
  53. #if UNITY_IPHONE
  54. // MoPubBinding.showInterstitialAd(BannerAdUnitId);
  55. #endif
  56. HasAdware = false;
  57. #if UNITY_ANDROID
  58. ////MoPubAndroid.requestInterstitalAd(BannerAdUnitId);
  59. #endif
  60. #if UNITY_IPHONE
  61. // MoPubBinding.requestInterstitialAd(BannerAdUnitId, null);
  62. #endif
  63. }
  64. }
  65. }