From my understanding, the coding is correct, the button to start the video works, however the advertisement is not loading in either editor, or the build.
I am receiving these dummy logs:
- Dummy .ctor
UnityEngine.Debug.Log(Object)
- Dummy Initialize
UnityEngine.Debug.Log(Object)
-Dummy .ctor
UnityEngine.Debug.Log(Object)
-Dummy CreateRewardBasedVideoAd
UnityEngine.Debug.Log(Object)
-Dummy LoadAd
UnityEngine.Debug.Log(Object)
-Attached is the coding
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds;
using GoogleMobileAds.Api;
using UnityEngine.UI;
public class Admob : MonoBehaviour
{
private RewardedAd rewardedAd;
// Start is called before the first frame update
public void Start()
{
// Initialize the Google Mobile Ads SDK.
MobileAds.Initialize(initStatus => { });
string adUnitId;
#if UNITY_ANDROID
adUnitId = "ca-app-pub-3940256099942544/5224354917";
#elif UNITY_IPHONE
adUnitId = "ca-app-pub-3940256099942544/1712485313";
#else
adUnitId = "unexpected_platform";
#endif
this.rewardedAd = new RewardedAd(adUnitId);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the rewarded ad with the request.
this.rewardedAd.LoadAd(request);
}
private void UserChoseToWatchAd()
{
if (this.rewardedAd.IsLoaded())
{
this.rewardedAd.Show();
}
}
}
↧