Problem with unity adds.
I am using unity ads both interstitial and rewarded video adds . For the rewarded ads i am spawning the player when the user completes the rewarded video ads. But the issue is reward is generating when the user closes the interstitial ads . Below are the codes i am using for Unity ads.
Below script is for Interstitial ads. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Advertisements;
public class UnityAd : MonoBehaviour { string gameId = "3970145"; bool testMode = true; // Start is called before the first frame update void Start() { Advertisement.Initialize(gameId, testMode); }
 public void DisplayInterstitialID()
 {
     Advertisement.Show();
 }
}
Below script is for Rewarded ads. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Advertisements;
public class Admanager : MonoBehaviour, IUnityAdsListener { string gameId = "3970145"; bool testMode = true; string myPlacementId = "rewardedVideo";
 private ScoreManager theScoreManager;
 public GameObject gameOverObject;
 private PlayerController Player;
 private PlayerSpawn thePlayerSpawn;
 
 // Start is called before the first frame update
 void Start()
 {
     thePlayerSpawn = FindObjectOfType<PlayerSpawn>();
     Player = FindObjectOfType<PlayerController>();
     theScoreManager = FindObjectOfType<ScoreManager>();
     Advertisement.AddListener(this);
     Advertisement.Initialize(gameId, testMode);
 }
   
 public void displayVideoAdd()
 {
     Advertisement.Show(myPlacementId);
 }
 // Implement IUnityAdsListener interface methods:
 public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
 {
     // Define conditional logic for each ad completion status:
     if (showResult == ShowResult.Finished)
     {
       
         thePlayerSpawn.GenCharacter();
         theScoreManager.gameOver = false;
         gameOverObject.SetActive(false);
         
         // Reward the user for watching the ad to completion.
     }
     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 OnUnityAdsReady(string placementId)
 {
     // If the ready Placement is rewarded, show the ad:
     if (placementId == myPlacementId)
     {
         // Optional actions to take when the placement becomes ready(For example, enable the rewarded ads button)
     }
 }
 public void OnUnityAdsDidError(string message)
 {
     // Log the error.
 }
 public void OnUnityAdsDidStart(string placementId)
 {
     // Optional actions to take when the end-users triggers an ad.
 }
 // When the object that subscribes to ad events is destroyed, remove the listener:
 public void OnDestroy()
 {
     Advertisement.RemoveListener(this);
 }
}
I dont player to spawn when the user closes the interstial add.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                