Rewarded video takes 3+ clicks to load
Hello,
I have a rewarded video ad in my game, which reloads the last played level. It works perfectly - however when testing on my phone, I have to click the "try again" button 3+ times before the rewarded video even loads. Below is my code which is working but delayed. Any idea what could be going on? I am using the following. As you can see, I am not currently using the "HandleShowResult" because it wasn't working when I used that. It isn't required though I don't think because the video must load before the previous level loads. If it does not then nothing happens.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Monetization;
using UnityEngine.SceneManagement;
[RequireComponent (typeof (Button))]
public class Adss : MonoBehaviour
{
public static Adss Instance;
[SerializeField] Button myButton;
private string store_id = "######";
private string video_ad = "video";
private string rewarded_video_ad = "rewardedVideo";
private void Awake()
{
Monetization.Initialize(store_id, true); //when publish set to false
int sceneToContinue = PlayerPrefs.GetInt("SavedScene");//testing for new level save
if (Instance != null)
{
Destroy(gameObject);
}
else
{
Instance = this;
DontDestroyOnLoad(gameObject);
}
}
void Start()
{
myButton = GetComponent<Button>();
myButton.onClick.AddListener(Adss.Instance.PlayTheRewardedVideo);
Monetization.Initialize(store_id, true); //when publish set to false
}
public void PlayTheRewardedVideo()
{
Monetization.Initialize(store_id, true); //when publish set to false
if (Monetization.IsReady(rewarded_video_ad))
{
ShowAdPlacementContent ad = null;
ad = Monetization.GetPlacementContent(rewarded_video_ad) as ShowAdPlacementContent;
ad.Show();
PreviousLevel();
}
}
public void InitializeAds()
{
Monetization.Initialize(store_id, true); //when publish set to false
}
public void PreviousLevel()
{
FindObjectOfType<LoseCollider>().LoadLastLevel();
}
private void HandleShowResult(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
PreviousLevel();
break;
case ShowResult.Skipped:
break;
case ShowResult.Failed:
Debug.Log("Error");
break;
}
}
}
Your answer
Follow this Question
Related Questions
Unity Rewarded Ads not showing up? 1 Answer
Problems with revenue after getting 5000+ impressions 0 Answers
Is ad platform CPIMobi good or bad? 5 Answers
Unity ads troubles 2 Answers
Test ad still showing up. 1 Answer