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 /
  • Help Room /
avatar image
1
Question by Eemil_Ahonen · Dec 04, 2016 at 05:52 PM · ads

Unity Ad shows twice?

Hi i have a game that displays an add when has gotten over 10 points and dies. a weird bug appeared. After getting 10 points and dying the ad will display like normally and then after closing it, another ad will appear and it will play, but then everything works like it suppose to work.

My script trigger. if (dead) { if (deathCooldown <= 0) { if (Score.score >= 10) { ShowAd(); }

definition

 public void ShowAd()
     {
         if (Advertisement.IsReady())
         {
             Advertisement.Show("rewardedVideo", new ShowOptions(){resultCallback = HandleAdResult});
         }
     }
     private void HandleAdResult(ShowResult result)
     {
         switch (result)
         {
             case ShowResult.Finished:
                 Application.LoadLevel(Application.loadedLevel);
                 break;
             case ShowResult.Skipped:
                 Application.LoadLevel(Application.loadedLevel);
                 break;
             case ShowResult.Failed:
                 Debug.Log("Failed");
                 break;
         }
     }
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 Paricus · Dec 04, 2016 at 06:03 PM 0
Share

are you calling the ShowAd function twice possibly? is it called when both death conditions are met,so

 if(deathCoolDown <= 0 && Score.score >= 10)
 ShowAd();

3 Replies

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

Answer by Eemil_Ahonen · Dec 10, 2016 at 12:12 PM

Fixed it myself Just added AdShown Bool that was false.

 if (dead) { if (deathCooldown <= 0) { if (Score.score >= 10  && AdShown == false) { ShowAd(); }
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
avatar image
0

Answer by Eemil_Ahonen · Dec 04, 2016 at 06:37 PM

@Paricus im using that if(deathcooldown..... for other things aswell. and yes its called when player is dead, then it checks the deathcooldown and if it's 0 it checks if the score was over 10. if it wasn't ad will not show.

Comment
Add comment · Show 6 · 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 Paricus · Dec 04, 2016 at 06:52 PM 0
Share

put a debug.log in your ShowAd() function. if you get the same log twice, the function is being called twice after death, which might explain the problem

avatar image Eemil_Ahonen · Dec 04, 2016 at 08:58 PM 1
Share

@Paricus the problem doesn't appear on the unity. It shows the ad once and everything works correctly.

avatar image Paricus Eemil_Ahonen · Dec 04, 2016 at 09:40 PM 0
Share

have you got two ads under the same id by any chance, if not i'd recommend creating a test project with just the ad functionality and seeing if you have the same problem. if so its either a problem with unity ads or the script

avatar image Eemil_Ahonen Paricus · Dec 05, 2016 at 09:28 AM 0
Share

@Paricus the thing is under void update so that is the issue. tried putting Application.LoadLevel(Application.loadedLevel); under case ShowResult.Failed: but it still shows 2 ads because it's not fast enough. there should be a thing that checks if the ad is already played so it won't show another but i don't know how.

Show more comments
avatar image
0

Answer by unity_17194192410E90131A21 · Sep 22, 2021 at 06:59 PM

I found a good solution: just add in your RewardedVideo script this:

 private void OnDestroy()
     {
         Advertisement.RemoveListener(this);
     }

Another way it didn't disappear was in the next scene. Or the opposite - use one AdManager and add to it

 DontDestroyOnLoad(this);



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

81 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

Related Questions

need help with Heyzap 0 Answers

Unity Ads 0$ 1 Answer

Unity switches scenes when Ad is closed. 0 Answers

HeyZap xcode build error symbol(s) not found for architecture arm64 0 Answers

Unity ads only dummy on phone live 0 Answers


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