**Twenty() ia a button ,in my game when i press it ,on the consoole it desplays :Dummy ShowRewardBasedVideoAd, but when i build the game and I press the button ,nothing happens (on the android device)**
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds;
using GoogleMobileAds.Api;
using UnityEngine.SceneManagement;
public class videoAd : MonoBehaviour {
public static int Twen;
private RewardBasedVideoAd rewardBasedVideo;
// Use this for initialization
void Start () {
RequestInterstitial();
Twen = 15;
rewardBasedVideo = RewardBasedVideoAd.Instance;
rewardBasedVideo.OnAdRewarded += HandleOnReward;
}
// Update is called once per frame
void Update () {
}
public void Twenty()
{
ShowInterstitial();
}
private void ShowInterstitial()
{
if (rewardBasedVideo.IsLoaded())
{
rewardBasedVideo.Show();
}
}
private void RequestInterstitial()
{
#if UNITY_EDITOR
string adUnitId = "unused";
#elif UNITY_ANDROID
string adUnitId = " ca-app-pub-1324966xxxxxxxxxxxxxxxxxxxxx";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-39402560xxxxxxxxxxxxxxxxxxxx";
#else
string adUnitId = "unexpected_platform";
#endif
RewardBasedVideoAd rewardBasedVideo = RewardBasedVideoAd.Instance;
AdRequest request = new AdRequest.Builder().Build();
rewardBasedVideo.LoadAd(request, adUnitId);
}
public void HandleOnReward(object sender, Reward args)
{
PlayerPrefs.SetInt("Points", Gamecontroller.PointsNow + Twen);
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
}
↧