My current account is still under approval but i guess this doesn’t matter.
This is my code:
using System;
using System.Threading;
using UnityEngine;
using UnityEngine.Advertisements;
public class AdsInitializer : MonoBehaviour
{
public static bool isLoaded = false;
public GameObject player;
public Canvas Gamecanvas;
public Canvas losecanvas;
public string appid = "1ea9478b5";
void Start()
{
IronSource.Agent.init(appid);
IronSource.Agent.validateIntegration();
IronSourceEvents.onSdkInitializationCompletedEvent += SdkInitializationCompletedEvent;
losecanvas.enabled = false;
IronSourceRewardedVideoEvents.onAdRewardedEvent += RewardedVideoOnAdRewardedEvent;
}
private void SdkInitializationCompletedEvent() { }
void RewardedVideoOnAdRewardedEvent(IronSourcePlacement placement, IronSourceAdInfo adInfo)
{
//TODO - here you can reward the user according to the reward name and amount
Debug.Log("Rewarded");
isLoaded = true;
}
public void continuegame()
{
bool available = IronSource.Agent.isRewardedVideoAvailable();
if (available)
{
IronSource.Agent.showRewardedVideo();
}
else { Debug.Log("Unavailable"); }
}
public void Restart()
{
player.transform.position = new Vector3(-5.6f, -3.2f, 0);
player.SetActive(true);
losecanvas.enabled = false;
Time.timeScale = 1f;
Gamecanvas.enabled = true;
}
void OnApplicationPause(bool isPaused)
{
IronSource.Agent.onApplicationPause(isPaused);
}
}
I would call the continuegame function everytime button is pressed. However, the code always gives out “unavailable” and I don’t know how to solve it.