I have two scenes in my project. There is only one award-winning video for each scene. In first scene, Everthing is okey, but if you come to second scene to first scene, i can't give reward to users and endofRewarded panel is not visible. What is the correct method for giving reward? How can i do that?
P.s : I know the tutorial is here. https://developers.ironsrc.com/ironsource-mobile/unity/rewarded-video-integration-unity/
But, I am beginner. Thank you.
Here is my code for first scene :
public class RewardedMain : MonoBehaviour
{
public string appkey;
public GameObject endofRewarded, anaEkran;
// Start is called before the first frame update
void Start()
{
IronSource.Agent.shouldTrackNetworkState(true);
IronSourceEvents.onRewardedVideoAvailabilityChangedEvent += RewardedVideoAvaibilityChangedEvent;
IronSourceEvents.onRewardedVideoAdClosedEvent += RewardedVideoAdClosedEvent;
IronSourceEvents.onRewardedVideoAdRewardedEvent += RewardedVideoAdRewardedEvent;
//IronSourceEvents.onRewardedVideoAdReadyEvent += OnRewardedVideoAdReady;
}//END START
public void showRewarded()
{
if (IronSource.Agent.isRewardedVideoAvailable())
{
anaEkran.SetActive(false);
IronSource.Agent.showRewardedVideo("MainRewarded");
}
}
void RewardedVideoAdClosedEvent()
{
IronSource.Agent.init(appkey, IronSourceAdUnits.REWARDED_VIDEO);
IronSource.Agent.shouldTrackNetworkState(true);
}
void RewardedVideoAvaibilityChangedEvent(bool available)
{
bool rewardedVideoAvailability = available;
}
void RewardedVideoAdRewardedEvent(IronSourcePlacement ssp)
{
PlayerPrefs.SetInt("totalCoin", PlayerPrefs.GetInt("totalCoin") + 150);
GameObject.Find("GoldNumberText").GetComponent<Text>().text = PlayerPrefs.GetInt("totalCoin").ToString();
SoundManager.Instance.PlayEarnGoldSound();
endofRewarded.SetActive(true);
}