Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Oliversgame · Jul 05, 2018 at 01:20 PM · videoadsadmobcoin

Admob rewarded video give more and more reward. Why

I have a shop scene where you can watch ad for 10 coin. Every time i open that scene give + 10 coin if i watch the ad.

So First time when i watch the ad give me 10 coin. When i leave the shop scene and go back and watch the ad will give me 20 coin. And again i leave the shop scene and go back and watch the ad will give me 30 coin. and so on.

Why is it for?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image madks13 · Jul 05, 2018 at 01:32 PM 0
Share

Can you post the code to analyse? Otherwise it's hard to tell.

3 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by Sonky108 · Jul 06, 2018 at 01:56 PM

The reason why this happen is because every Start you subscribe to an event without unsubscribing at all. Unsubscribe events on OnDestroy/OnDisable. Does multiple prints occured?

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Oliversgame · Jul 06, 2018 at 02:18 PM 0
Share

I tried that when i leave the scene destroy the script and when open the scene inserted the script but not worked. same issue!

did you think of this? @Sonky108

avatar image Sonky108 Oliversgame · Jul 06, 2018 at 02:31 PM 0
Share

Destroying the script or the object is not a solution here. Every time you subscribe to something You have to unsubscribe. Without doing this RewardBaseVideoAd keeps reference to the callback preventing GarbageCollector from removing the object. Check the link below[https://docs.microsoft.com/en-us/dotnet/csharp/program$$anonymous$$g-guide/events/how-to-subscribe-to-and-unsubscribe-from-events] [1]

[1]: https://docs.microsoft.com/en-us/dotnet/csharp/program$$anonymous$$g-guide/events/how-to-subscribe-to-and-unsubscribe-from-events

avatar image Oliversgame Sonky108 · Jul 06, 2018 at 07:27 PM 0
Share

Thank you :) work well. I dont know the admob's example why not contain this.

Show more comments
avatar image
0

Answer by Oliversgame · Jul 06, 2018 at 03:47 AM

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using GoogleMobileAds;
 using GoogleMobileAds.Api;
 using System;
 
 public class rewardvideo : MonoBehaviour {
 
     private RewardBasedVideoAd rewardBasedVideo;

     public void Start()
     {
         // Get singlet on reward based video ad reference.
     this.rewardBasedVideo = RewardBasedVideoAd.Instance;

     // RewardBasedVideoAd is a singleton, so handlers should only be registered once.
     this.rewardBasedVideo.OnAdLoaded += this.HandleRewardBasedVideoLoaded;
     this.rewardBasedVideo.OnAdFailedToLoad += this.HandleRewardBasedVideoFailedToLoad;
     this.rewardBasedVideo.OnAdOpening += this.HandleRewardBasedVideoOpened;
     this.rewardBasedVideo.OnAdStarted += this.HandleRewardBasedVideoStarted;
     this.rewardBasedVideo.OnAdRewarded += this.HandleRewardBasedVideoRewarded;
     this.rewardBasedVideo.OnAdClosed += this.HandleRewardBasedVideoClosed;
     this.rewardBasedVideo.OnAdLeavingApplication += this.HandleRewardBasedVideoLeftApplication;
 }

 public void Update()
 {

 }

 public void Clickonrewardreqest()
 {




     this.RequestRewardBasedVideo ();
     //Debug.Log ("s");



 }

 public void Clickonrewardshow()
 {
     this.ShowRewardBasedVideo ();



 }

 private void RequestRewardBasedVideo()
 {


     string adUnitId = "ca-app-pub-3940256099942544/5224354917";


     rewardBasedVideo.LoadAd (new AdRequest.Builder ().Build (), adUnitId);


 }



 private void ShowRewardBasedVideo()
 {
     if (this.rewardBasedVideo.IsLoaded())
     {
         this.rewardBasedVideo.Show();

     }
     else
     {
         MonoBehaviour.print("Reward based video ad is not ready yet");
     }
 }





 #region RewardBasedVideo callback handlers

 public void HandleRewardBasedVideoLoaded(object sender, EventArgs args)
 {
     MonoBehaviour.print("HandleRewardBasedVideoLoaded event received");
 }

 public void HandleRewardBasedVideoFailedToLoad(object sender, AdFailedToLoadEventArgs args)
 {
     MonoBehaviour.print(
         "HandleRewardBasedVideoFailedToLoad event received with message: " + args.Message);
 }

 public void HandleRewardBasedVideoOpened(object sender, EventArgs args)
 {
     MonoBehaviour.print("HandleRewardBasedVideoOpened event received");
 }

 public void HandleRewardBasedVideoStarted(object sender, EventArgs args)
 {
     MonoBehaviour.print("HandleRewardBasedVideoStarted event received");
 }

 public void HandleRewardBasedVideoClosed(object sender, EventArgs args)
 {
     MonoBehaviour.print("HandleRewardBasedVideoClosed event received");
 }

 public void HandleRewardBasedVideoRewarded(object sender, Reward args)
 {
     
     coin.Coin += 10;
     string type = args.Type;
     double amount = args.Amount;

         MonoBehaviour.print(
     "HandleRewardBasedVideoRewarded event received for " + amount.ToString() + " " + type);
 }

 public void HandleRewardBasedVideoLeftApplication(object sender, EventArgs args)
 {
     MonoBehaviour.print("HandleRewardBasedVideoLeftApplication event received");
 }

     #endregion
 }

@madks13

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image madks13 · Jul 06, 2018 at 08:37 AM 0
Share

Hmm, this is not enough info. What is coin.Coin? what is Amount? Do you use "amount" or "coin.Coin" to check what was awarded? Based on your code, i'd guess amount, but where do you get amount from? Is the player purse amount or coin.Coin? From what i see, i guess amount is the total amount in player's purse rather than the amount awarded. Can you check those?

avatar image Oliversgame madks13 · Jul 06, 2018 at 01:52 PM 0
Share

@madks13 actually i dont know what is this line in the script:

double amount = args.Amount;

I find this whole script on the admob's website. Without this line work the same.

In fact just the coin.Coin need, that gives the reward. The coin.Coin is just a simple static integer.

avatar image
0

Answer by Ex6tra · Jul 12, 2020 at 09:12 PM

Your problem is that you're subscribing to events more than once which results in the reward event being called more than once, to prevent that you should put your subscribing events in a method that only executes once like the Show reward ad method. if the problem occurs you should make sure that you're unsubscribing from the reward events every time the scene loads. In general you should subscribe when showing reward ad and unsubscribe when the player is rewarded

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

92 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Admob video ad shows only once on the phone ? 1 Answer

admob legacy api can load multiple video ads but new api doesn't ? 0 Answers

Video Ads not showing correctly on IOS 1 Answer

Admob Reward video not showing up, but the test ad unit is showing. 2 Answers

admob rewarded video ad dont reward 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges