void Start()
{
MobileAds.Initialize(appID); // app ID is the real App-ID from AdMob
rewardedAd = RewardBasedVideoAd.Instance;
rewardedAd.OnAdRewarded += HandleRewardBasedVideoRewarded;
}
void RequestRewardedAd()
{
Debug.Log("Requested RewardedAd");
debugText.text = "Requested RewardedAd";
AdRequest request = new AdRequest.Builder().AddTestDevice("testDeviceID").Build(); // testDeviceID is a string with unique test device N°
rewardedAd.LoadAd(request, DUMMY_rewardedAdID); // I'm using the rewarded ad test-ID provided by AdMob here
}
// This is Button the player presses on the device to start the ad
public void SHOW_REWARDED_AD()
{
StartCoroutine(ShowRewardedAd());
}
public IEnumerator ShowRewardedAd()
{
// Request an rewarded ad
RequestRewardedAd();
// wait for rewarded ad to load
while (!rewardedAd.IsLoaded())
Debug.Log("currently loading rewarded ad");
debugText.text = "currently loading rewarded ad";
yield return null;
if (rewardedAd.IsLoaded())
{
Debug.Log("we reached leaded state");
debugText.text = "we reached loaded state";
rewardedAd.Show(); // Show the ad
}
else
{
Debug.Log("REWARDED-AD NOT LOADED! CHECK INTERNET CONNECTION AND APP_ID!!");
debugText.text = "REWARDED-AD NOT LOADED! CHECK INTERNET CONNECTION AND APP_ID!!";
}
}
///////////////////////////////////////////
/// HANDLE THE REWARDS THE PLAYER GETS ////
/// ///////////////////////////////////////
public void HandleRewardBasedVideoRewarded(object sender, Reward args)
{
Debug.Log("hello world"); // this gets printed
string type = args.Type;
double amount = args.Amount;
Debug.Log("You have been awarded with " + amount.ToString() + " " + type); // this works as well
// APP CRASHES WHEN DOING ONE OF THE FOLLOWING THINGS:
debugText.text = ("You have been awarded with " + amount.ToString() + " " + type); // this DOESN't WORK (And let's the application crash)
RewardButton.SetActive(true); // this also let's the application crash
ReceiveRewards(); // this also let's the application crash
SomeOtherScriptFromTheProject.instance.SayHelloToWorld(); // also doesn't work
}
public void ReceiveReward()
{
debugText.text = "REWARDS HAVE BEEN RECEIVED";
GemRewardButton.SetActive(false);
}}
Hi there,
Thank you for reaching out to us.
Could you kindly provide the details below (via Reply to author or a direct, private reply to this email) so that I can investigate the issue?
You may zip the entire Unity project (excluding the Library and Temp folders) in order to reduce its size, then send it to me via a shareable link from your Google Drive (or on any other file-sharing site that you prefer). Don't forget to send via Reply to author or a direct, private reply to this email.
|
||||||