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
0
Question by andrew_2992 · Dec 14, 2016 at 11:09 AM · adsadvertisingunityads

Unity ads strange problem

Hello forum, I've been searching all night for someone who's encountered the same issue as me here but I haven't found anybody so I'll post my problem.

Short version - ads show the first time when going from my menu to my level, but when I go back to my main menu and try to start the next level, the advertisement displays and the close button in the top right corner of the ad doesn't do anything.

Now in case there is some specific crucial problem I'm creating here I'll explain more about the whole process of moving between levels and calling ShowAd(). - When my game starts I call Advertisement.Initialize() in awake() and when the player starts a level I call ShowAd() using some code which I ripped right out of the unity tutorial for unity ads. The demo ad shows fine and when I click close, my game proceeds to the level as expected. The showAd() and Advertisement.Initialize() functions are called from a singleton object that I use to load the player profile, write profile data to the menu, and load scenes.

Upon completing the level, I save the gamer profile and destroy the singleton where I called the ShowAd() function from before returning to the main menu. (This is so that when I return to my main menu I can get all the references to all the menu items and images etc that I have assigned through the editor, without having to find them through script in the start function of the singleton (I have it set to not destroy on load so that it is present in the level but I destroy it before returning to the menu so I can get a fresh one)).

So when the main menu loads again there is a fresh singleton object there and the game runs the load process of the player profile again. Everything is fine in my menu scene and all data is loaded just as it was before the level was played. However when I try to play the level again and showAd() is called for the second time in the game session the button to close the ad has no effect at all. (Different object calling it now, same class but different instance, as the first one was destroyed at the end of the level).

I included the process here because I'm not sure if it matters... One thing I thought was maybe Advertisement.Initialize() could only be called once per session but I read online that it doesn't matter. If anything is unclear let me know and I can provide some more details.

One final note, there's no error or message in the editor console or in the more in depth Editor.txt log. Just "UnityAdsEditor: Show(, );"

 public void ShowAd(string zone = "")
     {
         #if UNITY_EDITOR
         StartCoroutine(WaitForAd ());
         #endif
 
         if (string.Equals (zone, ""))
             zone = null;
 
         ShowOptions options = new ShowOptions ();
         options.resultCallback = AdCallbackhandler;
 
         if (Advertisement.IsReady (zone))
             Advertisement.Show (zone, options);
     }
 
     void AdCallbackhandler (ShowResult result)
     {
         switch(result)
         {
         case ShowResult.Finished:
             Debug.Log ("Ad Finished. Rewarding player...");
             break;
         case ShowResult.Skipped:
             Debug.Log ("Ad skipped. Son, I am dissapointed in you");
             break;
         case ShowResult.Failed:
             Debug.Log("I swear this has never happened to me before");
             break;
         }
     }
 
     IEnumerator WaitForAd()
     {
         float currentTimeScale = Time.timeScale;
         Time.timeScale = 0f;
         yield return null;
 
         while (Advertisement.isShowing)
             yield return null;
 
         Time.timeScale = currentTimeScale;
     }
 
Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

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

61 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

Related Questions

OnUnityAdsShowComplete not working 2 Answers

How do you monetize games for Windows Phone, Windows (PC) and the Web? 0 Answers

Problem with 'AdsManager.UnityAdsShowVideo()' is deprecated 0 Answers

Tried Everything, Cant get ads to show! 0 Answers

User-initiated ads VS click fraud 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