Reputation: 37
I'm having problems with my code, you see I imported Google Admob into my project. I integrated the reward system into my AdManager script, using Github's Plugin Wiki and Documentation. However (in my AdManager script) my rewarding the user function isn't really working, I have a static int from another script that gives my player a boomerang when they pick it up in the game, buy it or receive from watching a video. Below is my AdManager script:
public class AdManager : MonoBehaviour
{
public static AdManager Instance { set; get; }
public string bannerId;
public string videoId;
private void Start()
{
Instance = this;
DontDestroyOnLoad(gameObject);
#if UNITY_EDITOR
#elif UNITY_ANDROID
Admob.Instance().initAdmob(bannerId, videoId);
Admob.Instance().setTesting(true);
Admob.Instance().loadInterstitial();
Admob.Instance().rewardedVideoEventHandler += onRewardedVideoEvent;
#endif
}
public void Reward()
{
Admob ad = Admob.Instance();
if (ad.isRewardedVideoReady())
{
ad.showRewardedVideo();
}
else
{
ad.loadRewardedVideo("ca-app-pub-2099082167446861/xxxxxxxxxx");
}
}
void onRewardedVideoEvent(string eventName, string msg)
{
WeaponScript.boomerang += 1;
Debug.Log("Well Done! You have been rewarded one Boomerang!");
Debug.Log("handler onRewardedVideoEvent---" + eventName + " " + msg);
}
}
My problem: I built the game and tried it out, watched a video got a reward (boomerang), but when I did it again (watch another reward video) I didn't get another reward (boomerang). Not sure if I'm doing it wrong. Please can anyone help me with my problem. Thank you!
Upvotes: 0
Views: 201