Here is my code:
----------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds;
using GoogleMobileAds.Api;
public class GoogleAdMobADS : MonoBehaviour {
public bool pr;
// Use this for initialization
private RewardBasedVideoAd rewardBasedVideo;
public void Start()
{
pr = false;
// Get singleton reward based video ad reference.
//this.rewardBasedVideo = RewardBasedVideoAd.Instance;
// Get singleton reward based video ad reference.
this.rewardBasedVideo = RewardBasedVideoAd.Instance;
this.RequestRewardedVideo();
}
// Update is called once per frame
void Update () {
if (rewardBasedVideo.IsLoaded())
{
pr=true;
rewardBasedVideo.Show();
}
}
private void RequestRewardedVideo()
{
//ca-app-pub-3940256099942544/5224354917
string adUnitId = "ca-app-pub-3940256099942544/5224354917";
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the rewarded video ad with the request.
rewardBasedVideo.LoadAd(request, adUnitId);
}
}
----------
I wrote this code in the script and added that script to empty game object on the scene. After that I made game and tested the game on Android device, but before that I had tested game in unity editor too. Ads are not showing. Thank you in advance!
↧