Search Unity

UnityAdsHelper Issue

Discussion in 'Unity Ads & User Acquisition' started by Reymus, Oct 25, 2015.

  1. Reymus

    Reymus

    Joined:
    Apr 27, 2015
    Posts:
    44
    Hi all.

    So, as I mentioned in an earlier thread, I updated to Unity 5.2, and had to remove the Asset store version of Unity Ads. I did so, and ran into a problem with it not recognizing my UnityAdsHelper scripts. I've removed the old version of the script, as requested, and installed the new version, and it doesn't seem to be recognizing it.

    I attached the UnityAdsHelper script to my UnityAdsManager object, and when I try to reference that script to play a video, the button shows <Missing.UnityAdsHelper.ShowVideo> in the Inspector under OnClick().

    The install document says I should also see UnityAdsHelper under the Edit menu in order to edit settings, and it's not there either.

    Any ideas?
     
  2. Reymus

    Reymus

    Joined:
    Apr 27, 2015
    Posts:
    44
    So it's looking like UnityAdsHelper isn't being initialized at all, which is what's causing my issue. I have no idea how I would go about fixing that. I've tried removing it again and reinstalling it, to no change.
     
  3. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    The UnityAdsHelper script found in the Unity Ads Helper project contains static methods, which can't be referenced from the UI Button. There is an example button script that defines a non-static ShowAd method, which can be referenced from the UI Button. The non-static ShowAd method assigns the callback for handling the result and calls the static UnityAdsHelper.ShowAd method.

    To use the UnityAdsHelper, you want to write your own scripts that call the static methods contained within the helper. The helper manages the Unity Ads implementation, while your scripts serve as the actual use case implementations.

    Does that help?

    The README covers this in more detail. If you're enabling Ads through the Services window Unity 5.2, you can skip over the instructions on how to configure the UnityAdsSettings asset. You can configure settings through the Services window instead. The UnityAdsHelper knows when you're using Unity 5.2 or later and lets it take over for setup and initialization.

    Since Unity is handling the initialization of Unity Ads in 5.2, you don't even need to add the UnityAdsHelper script to your scene. Since the helper methods are all static, they can be referenced from your own scripts, as instructed through examples in the README.

    Check out the section on Using a Unity UI Button to Show Ads for more details.
     
  4. Reymus

    Reymus

    Joined:
    Apr 27, 2015
    Posts:
    44
    This worked perfectly.
     
    unity-nikkolai likes this.