public class GameAdvertisement : MonoBehaviour
{
public SaveLoad saveReference;
private RewardBasedVideoAd rewardBasedVideo;
public AdRequest request;
private string adUnitId = "ca-app-pub-2431865456328128/8772653896";
private bool rewardBasedEventHandlersSet;
void Start()
{
RequestRewardBasedVideo();
}
//Admob
private void RequestRewardBasedVideo()
{
rewardBasedVideo = RewardBasedVideoAd.Instance;
request = new AdRequest.Builder().Build();
rewardBasedVideo.LoadAd(request, adUnitId);
rewardBasedEventHandlersSet = false;
}
public void ShowAdmobRVideo() //this is the method attached to my "Watch Video" button
{
if (rewardBasedVideo.IsLoaded())
{
rewardBasedVideo.Show();
rewardBasedEventHandlersSet = true;
}
if (!rewardBasedVideo.IsLoaded())
{
rewardBasedVideo.LoadAd(request, adUnitId);
}
if (!rewardBasedEventHandlersSet)
{
rewardBasedVideo.OnAdRewarded += HandleRewardBasedVideoRewarded;
rewardBasedEventHandlersSet = true;
}
}
public void HandleRewardBasedVideoRewarded(object sender, Reward args)
{
string type = args.Type;
double amount = args.Amount;
print("User rewarded with: " + amount.ToString() + " " + type);
saveReference.playerLifes += 5; //this is the place where the reward should be added. Not sure if this line should be here or somewhere else
}
}
Google Mobile Ads Unity v3.1.3 (also tried to downgrade and it didn't worked)
Google Play Services 0.9.36
Test Device: Android 5.0
--
---
You received this message because you are subscribed to a topic in the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/ea8lE5l2z5I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.