Unity Ads no result

Hello,
I am using Unity Ads and I managed to show ads in game, but when it came to result, I am getting none.
The script I am using (its only the Ad function)

    public void ThrowAd ()
    {
     
        if (Advertisement.isSupported) {
         
            ShowOptions options = new ShowOptions();
            ShowResult result = new ShowResult();
            Advertisement.Initialize ("My Unpublished Game ID", false);
            if (Advertisement.isReady (zoneId: "rewardedVideoZone")) {
             
                options.pause = true;
                AdsD = AdsDelay;
                Advertisement.Show("rewardedVideoZone");
             
            } else {
             
                AdDetails.text = "Ad not loaded";
             
            }
            options.resultCallback = results => {
             
                switch (result) {
                 
                case(ShowResult.Failed):
                 
                    AdDetails.text = "Ad failed!";
                 
                    break;
                 
                case(ShowResult.Finished):
                 
                    if (AdType == 1) {
                     
                        AdDetails.text = "You just earned a gem!";
                     
                    } else {
                     
                        AdDetails.text = "Thanks for watching the Ad";
                     
                    }
                 
                    break;
                 
                case(ShowResult.Skipped):
                 
                    AdDetails.text = "Ad was skipped :(";
                 
                    break;
                }
             
            };
        }
    }

It shows the ad perfectly but do not give any reward/message to me. (Unity Remote not working so cant debug log (Already tried text fields)).
Also it gives me a error while viewing the picture ad (yes videos are not coming) that says ‘Video Playback Error’. Please Help!

The Video Playback Error occurs when the video fails to stream due to poor network conditions.

There are a few of issues with your code:

  • You call initialize shortly before the Show() method; Unity Ads won’t be ready in time to show.
  • When calling the Show() method, you left out the options parameter.
  • You assign a value to resultCallback after the point that it should be referenced.
public string gameID;
public bool enableTestMode;

void Start ()
{
    if (Advertisement.isSupported)
    {
        Advertisement.Initialize(gameID,enableTestMode)
    }
}

public void ThrowAd ()
{
    if (Advertisement.isReady("rewardedVideoZone"))
    {
        ShowOptions options = new ShowOptions();
        options.resultCallback = results => {
            switch (result)
            {
            case(ShowResult.Failed):
                AdDetails.text = "Ad failed!";
                break;

            case(ShowResult.Finished):
                if (AdType == 1) AdDetails.text = "You just earned a gem!";
                else AdDetails.text = "Thanks for watching the Ad";
                break;

            case(ShowResult.Skipped):
                AdDetails.text = "Ad was skipped :(";
                break;
            }
        };
        options.pause = true;
      
        AdsD = AdsDelay;
      
        Advertisement.Show("rewardedVideoZone",options);
    }
    else AdDetails.text = "Ad not loaded";
}

ok thanks :slight_smile: my network was slow so video playback error was occurring. thanks it solved my problem

so can I allow precache in start/awake.

edit- Again if i skip/complete the ad no result still

I edited the script still not working

public void ThrowAd ()
    {
        if (Advertisement.isReady ("rewardedVideoZone")) {
            ShowOptions options = new ShowOptions ();
            options.pause = true;
            options.resultCallback = HandleShowResult;
            AdsD = AdsDelay;
            Advertisement.Show ("rewardedVideoZone");

        } else {

            AdDetails.text = "Ad not loaded";

        }
    }
    void HandleShowResult(ShowResult result) {
       
        switch (result) {
        case(ShowResult.Failed):
            AdDetails.text = "Ad failed!";
            break;
           
        case(ShowResult.Finished):
            if (AdType == 1) {
                AdDetails.text = "You just earned a gem!";
            } else {
                AdDetails.text = "Thanks for watching the Ad";
            }
            break;
           
        case(ShowResult.Skipped):
            AdDetails.text = "Ad was skipped :(";
            break;
        }
    }

:(:(:(:(:(:(:frowning:
Please help only the Ad system is left in my game

You’re still not passing the options parameter when calling show. You need to pass options like so:

Advertisement.Show ("rewardedVideoZone",options);

Without that parameter, the result callback will not be called.

1 Like

oh I see I need the second parameter of options to make the script follow the functions. I try it Thanks
:slight_smile:

Thanks a lot. It is working now!

Can anyone post complete error-free script ?

Can you use the http://docs.unity3d.com/ScriptReference/Advertisements.Advertisement.Show.html example?

1 Like