unity rewarded video ad not working after loading a scene
Hello; i am facing a issue with my unity rewarded video ad. in the first scene the video rewarded ad is working fine . and when I enter scene 2 with a trigger. rewarded video ad won't load.
as if the listener is destroyed. how to show video rewarded ad after I enter scene 2.
Answer by Rainbowin · Mar 25, 2021 at 08:08 AM
of course no reply, I never get a reply here.
Hey Buddy I'm facing the same problem did you solved that?
first i created two scripts (Rwarded video ads both have the same IDsurfacing) when video is completed I remove the listener
public void OnUnityAdsDidFinish (string surfacingId, ShowResult showResult) { // Define conditional logic for each ad completion status: if (showResult == ShowResult.Finished) { // Reward the user for watching the ad to completion.
Player.transform.position = ExitPosition.transform.position;
Player.transform.rotation = ExitPosition.transform.rotation;
Advertisement.RemoveListener(this);
Debug.Log("Listener From First Section is Removed");
Debug.Log("Rewarded Video Ad is Finished Player In First Section is Teleported To Exit");
}
when you start a new scene you will addlistener in start method
start func. Advertisement.AddListener (this); Advertisement.Initialize (gameId, testMode);
what if scene is loaded and you lose, listener is already on how would you reload ads?
in both scripts for rewarded video ads, I used
void Awake() { Advertisement.Load(mySurfacingId); Debug.Log("Advertisment is Loaded in First Section"); }
you load the advertisement
so.. - remove listeners when video is completed - awake() Func. use Advertisement.Load(mySurfacingId); so if you lose video will reload
Answer by Digital_Owl · May 01 at 09:34 AM
hey, some time passed and i still have exact same problem, im really hard stuck on this any suggestion what i can do?
Add Remove listener in your script, example:
public void OnUnityAdsDidFinish (string surfacingId, ShowResult showResult) {
// Define conditional logic for each ad completion status:
if (showResult == ShowResult.Finished) {
// Reward the user for watching the ad to completion.
Player.transform.position = ExitPosition.transform.position;
Player.transform.rotation = ExitPosition.transform.rotation;
Advertisement.RemoveListener(this);
Debug.Log("Listener From First Section is Removed");
Debug.Log("Rewarded Video Ad is Finished Player In First Section is Teleported To Exit");
}
In this case when the scene is reloaded the script will add new listener, make sure to add awake func. example:
void Start()
{
Advertisement.AddListener (this);
Advertisement.Initialize (gameId, testMode);
RewardedVideoButton.interactable = false;
RewardedVideoMessage.SetActive(false);
}
void Awake() {
Advertisement.Load(mySurfacingId);
Debug.Log("Advertisment is Loaded in First Section");
}
Your answer
Follow this Question
Related Questions
Unity object custum events and sendmessage 0 Answers
can i apply an ad on a material 1 Answer
UnityAds.initialize() FPS drops on iOS 0 Answers
Infinite login redirect unity services 2 Answers
How to use unity rewarded ads? 1 Answer