I have no idea what I am doing wrong, I have each script attached to a button to run the add when I click the button but nothing happens, using unity ads of course and I have two buttons to reward coins after clicking like I said after clicking nothing, am I missing something in my code or what, any response is much appreciated. thank you
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Advertisements;
public class RewardedAdsMenu : MonoBehaviour {
public SoundManager sm;
public GameObject PickReward;
int CoinsBonus;
int CoinsAds;
int WatchAds;
int CoinsAdsZzz;
public void ShowRewardedAd()
{
if (Advertisement.IsReady("rewardedVideo"))
{
var options = new ShowOptions { resultCallback = HandleShowResult };
Advertisement.Show("rewardedVideo", options);
}
}
private void HandleShowResult(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
Debug.Log("The ad was successfully shown.");
sm = GameObject.Find("PlayZone").GetComponent();
WatchAds = PlayerPrefs.GetInt("WatchAds",0);
CoinsAds = PlayerPrefs.GetInt("CoinsAds", 100);
CoinsBonus = PlayerPrefs.GetInt("ShipCoinBonus", 1);
CoinsAdsZzz = CoinsAds*CoinsBonus;
PlayerPrefs.SetInt("CoinsAdsZzz", CoinsAdsZzz);
PickReward.SetActive(true);
WatchAds++;
PlayerPrefs.SetInt("GetRewardCoins",1);
PlayerPrefs.SetInt("WatchAds",WatchAds);
sm.PlaySound(0);
break;
case ShowResult.Skipped:
Debug.Log("The ad was skipped before reaching the end.");
break;
case ShowResult.Failed:
Debug.LogError("The ad failed to be shown.");
break;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Advertisements;
public class RewardedAdsPlay : MonoBehaviour {
public SoundManager sm;
public int DoubleCoins;
public Text DoubleCoinsText;
public GameObject DoubleCoinBtn;
public GameObject NeDoubleCoinBtn;
public GameObject DoubleNextBtn;
int CoinsC;
int WatchAds;
public void ShowRewardedAd()
{
if (Advertisement.IsReady("rewardedVideo"))
{
var options = new ShowOptions { resultCallback = HandleShowResult };
Advertisement.Show("rewardedVideo", options);
}
}
private void HandleShowResult(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
Debug.Log("The ad was successfully shown.");
sm = GameObject.Find("PlayZone").GetComponent();
CoinsC = PlayerPrefs.GetInt("Coins",0);
WatchAds = PlayerPrefs.GetInt("WatchAds",0);
DoubleCoins = PlayerPrefs.GetInt("CoinsForGame", 0);
CoinsC = PlayerPrefs.GetInt("Coins",0);
CoinsC += DoubleCoins;
DoubleCoins += DoubleCoins;
DoubleCoinsText.text = DoubleCoins.ToString();
WatchAds++;
PlayerPrefs.SetInt("WatchAds",WatchAds);
PlayerPrefs.SetInt("Coins",CoinsC);
DoubleCoinBtn.SetActive(false);
NeDoubleCoinBtn.SetActive(false);
DoubleNextBtn.SetActive(true);
PlayerPrefs.SetFloat("TimerDouble", 120);
sm.PlaySound(4);
break;
case ShowResult.Skipped:
Debug.Log("The ad was skipped before reaching the end.");
break;
case ShowResult.Failed:
Debug.LogError("The ad failed to be shown.");
break;
}
}
}
↧