Search Unity

  1. Engage, network and learn at Unite Austin 2017, Oct 3 - 5. Get your ticket today!
    Dismiss Notice
  2. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  3. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  4. Unity 2017.1 is now released.
    Dismiss Notice
  5. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  6. Unity 2017.2 beta is now available for download.
    Dismiss Notice

Need Help Displaying Ads

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

  1. Purplepigfarm

    Purplepigfarm

    Joined:
    Aug 10, 2016
    Posts:
    9
    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

    Unity Technologies

    Joined:
    Oct 25, 2016
    Posts:
    52
    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:
    9

    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

    Unity Technologies

    Joined:
    Oct 25, 2016
    Posts:
    52
    @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 :)