- Home /
Unity rewarded ad is not giving reward
In my game i give 30 sec to player when time end a gameover panal will be active and there a "10 sec extra" btn will be appear.... When i click this btn unity reward ad is showing but after that i don't get 10 sec time..... How will i give 10 sec time ..... Pls help
This is my unity rewarded ad script
using UnityEngine; using System.Collections; using UnityEngine.Advertisements; using UnityEngine.UI;
public class UnityAdManager : MonoBehaviour, IUnityAdsListener {
public static UnityAdManager Instance;
string gameId = "1234567";
bool testMode = true;
string placement_rewardedVideo = "rewardedVideo";
void Start () {
Advertisement.Initialize (gameId, testMode);
}
public void ShowRewardedAd() {
if (Advertisement.IsReady()) {
Advertisement.Show(placement_rewardedVideo);
}
else {
Debug.Log("rewarded ad not ready at the moment! Please try again later!");
}
}
public void OnUnityAdsDidFinish(string placement_rewardedVideo, ShowResult showResult)
{
Time.timeScale = 1;
if (showResult == ShowResult.Finished){
// Timer.instance.GameOverPanel.SetActive(false);
Timer.instance.timeStart += 10f;
// Timer.instance.textBox.text = Timer.instance.timeStart.ToString();
Debug.Log("you get reward");
}
else if (showResult == ShowResult.Skipped){
// Do not reward the user for skipping the ad.
}else if (showResult == ShowResult.Failed){
Debug.LogWarning("The ad did not finish due to an error.");
}
}
}
}
public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
{
Time.timeScale = 1;
if (showResult == ShowResult.Finished){
// Timer.instance.GameOverPanel.SetActive(false);
Timer.instance.timeStart += 10f;
// Timer.instance.textBox.text = Timer.instance.timeStart.ToString();
Debug.Log("you get reward");
}
else if (showResult == ShowResult.Skipped){
// Do not reward the user for skipping the ad.
}else if (showResult == ShowResult.Failed){
Debug.LogWarning("The ad did not finish due to an error.");
}
}
}
and below is my timer script
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class Timer : MonoBehaviour { public static Timer instance; public float timeStart = 0f; public Text textBox; public GameObject GameOverPanel; void Start() { textBox.text = timeStart.ToString();
GameOverPanel.SetActive(false); }
public void Update() {
timeStart -= Time.deltaTime;
textBox.text = timeStart.ToString("0");
if(timeStart <= 0){
timeStart = 0;
GameOver();
}
}
void GameOver(){
Time.timeScale = 0;
GameOverPanel.SetActive(true);
// we've to use gameObject
}
}
Your answer
Follow this Question
Related Questions
UnityAds Banner not showing up in production environment/build 10 Answers
Unity Ads Banner not working. 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers