Question by
jeaux221 · Apr 18, 2016 at 03:19 AM ·
playerprefsads
Increment value and save to PlayPrefs as RewardedAd reward.
What am I doing wrong?
using UnityEngine;
using UnityEngine.Advertisements;
public class PlayRewardedVideoScript : MonoBehaviour
{
public int markers;
void start()
{
markers = PlayerPrefs.GetInt("markers");
}
public void ShowRewardedAd()
{
if (Advertisement.IsReady("rewardedVideo"))
{
var options = new ShowOptions { resultCallback = HandleShowResult };
Advertisement.Show("rewardedVideo", options);
}
}
private void HandleShowResult(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
Debug.Log("The ad was successfully shown.");
//
// YOUR CODE TO REWARD THE GAMER
// Give coins etc.
markers += 100;
PlayerPrefs.SetInt("markers", markers);
PlayerPrefs.Save();
break;
case ShowResult.Skipped:
Debug.Log("The ad was skipped before reaching the end.");
break;
case ShowResult.Failed:
Debug.LogError("The ad failed to be shown.");
break;
}
}
}
Don't understand why this won't increment properly. The console shows that the ad was successfully shown... Many thx.
Comment
Your answer
Follow this Question
Related Questions
Faster Way to Increment PlayerPrefs Int 1 Answer
Playerprefs, i dont know how to use 0 Answers
Editor PlayerPrefs getting repopulated with deleted values 2 Answers
standard anti memory hack load save data using playerprefs 0 Answers
Persistent data between different games - local save for WebGL 0 Answers