Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Need Help Displaying Ads

Discussion in 'Unity Ads & User Acquisition' started by Purplepigfarm, Aug 21, 2017.

  1. Purplepigfarm

    Purplepigfarm

    Joined:
    Aug 10, 2016
    Posts:
    25
    Hello, I got this weird problem with displaying the unity ads. I have a simple c# script with a method to display an ad.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Advertisements;
    3. public class DisplayAd : MonoBehaviour
    4. {
    5.      public void ShowAd()
    6.      {
    7.          Debug.Log("showing ad");
    8.          Advertisement.Show();
    9.      }
    10. }

    Then I have a button in my scene that calls that method when it is clicked. However, when I click it, nothing happens (besides the debug log... that works). I'm currently running the latest version of Unity (2017.1.03f). I tried downgrading to see if that would work, but nothing changed. No editor settings have been changed, they are all default. Test mode is enabled and I have an internet connection. I did import the unity ads package from the asset store since the built in service didn't seem to be working (couldn't reference UnityEngine.Advertisements). That's about all the info I can think of. Thanks for reading and helping!
     
    Last edited: Aug 21, 2017
  2. ClaireO

    ClaireO

    Joined:
    Oct 25, 2016
    Posts:
    61
    Hi @Purplepigfarm

    The log is printing, so the method is being called.

    Do you have IsReady() checks? You should only call Show() if IsReady() returns true.

    I hope this helps.

    Kind Regards,

    Claire
     
  3. Purplepigfarm

    Purplepigfarm

    Joined:
    Aug 10, 2016
    Posts:
    25

    Hi @ClaireO

    Thanks for replying! and sorry for the late reply. I was troubleshooting my desktop all week.

    Anyway, I did indeed try using IsReady() earlier and the results were the same. I noticed that most others are able to get ads to display only calling Show(). For the sake of simplicity, I left it out.

    I'm wondering if perhaps the problem has to do with the built-in ads service not working. I did just figure this out though, but when I have both the built-in ads enabled and the ads package from the store installed and my build settings are switched to android, I get an script error saying UnityEngine.Advertisements is defined in two locations or something like that (I'll add the real error when I have time). It doesn't change on disabling build-in ad services, but it does after removing the ad package form the store.

    I hope I'm making sense, and thank you very much for the support!


    EDIT: Upon re-reading my last post, I now feel like an idiot.

    1. I had the build platform set as pc/mac/linux and not as Android or IOS.

    2. I did not initialize the ad service in my script with: Advertisement.Initialize("GameID");

    I disabled the built-in version of Unity ads and used the imported Unity ads instead. and it worked. Thanks once again.
     
    Last edited: Aug 25, 2017
  4. ClaireO

    ClaireO

    Joined:
    Oct 25, 2016
    Posts:
    61
    @Purplepigfarm around the time of your posting, we did not realize that there was an issue with ads playing in the editor. This has now been fixed. It may or may not have been the root cause of your issue.

    Either way, I am glad that it is now sorted for you :)