unity ads probleme !

Currently i’m using unity rewarded video ads ny cliking a button (the player should request an ad then he get rewarded) and it work fine in the editor even the message shows that the ad are working fine and and when i go to the emulator( Nox) the button is disabled (i uploaded the picture)
ps : i’m using unity ad asset from asset store/and unity version 5.6.0f3
and that my code :

using UnityEngine.UI;
using UnityEngine;
using UnityEngine.Advertisements;

[RequireComponent(typeof(Button))]
public class Playad : MonoBehaviour
{

#if UNITY_ANDROID
private string gameId = “*******”;
#endif
Button m_Button;

public string placementId = “rewardedVideo”;
public GameObject a;
public Transform player;

public void Start()
{
pH= GetComponent();
player = GameObject.FindGameObjectWithTag(“Player”).transform;
m_Button = GetComponent();
if (m_Button) m_Button.onClick.AddListener(ShowAd);

if (Advertisement.isSupported)

{
Advertisement.Initialize(gameId, true);
}

}
private void Update()
{
if (m_Button) m_Button.interactable = Advertisement.IsReady(placementId);
}

public void ShowAd()
{
var options = new ShowOptions();
options.resultCallback = HandleAdRresults;

Advertisement.Show(placementId, options);

}

private void HandleAdRresults(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:

Instantiate(a,player.position,Quaternion.identity );
Debug.Log(“health have been increased”);
break;
case ShowResult.Skipped:
Debug.Log(“player didnt complete”);
break;
case ShowResult.Failed:
Debug.Log(“Playrdidnt have intenet”);
break;
}
}
}

Hi,

Emulators aren’t really supported with Ads, as they might not provide all the necessary resources for the SDK.

Have you tried this on the device?

I’m using Nox and Unity Ads are always displayed, however, some Ads are shown in a bad resolution. I did some testing with GoogleMobileAds and the rewarded videos are not displayed at all on Nox but on device they still work…

If it works in the Editor, it should work on device too…

Last week I had three major issues with Unity Ads, I’m testing on 7 iOS and Android devices:

  • On my old Galaxy Tab 2, Ads always failed, however on 4 newer devices they worked perfect…
  • Ads where not working in the editor for about 24 hours but everything seems to work fine again…
  • For 3 days Ads failed on my iPhone 4S and on my iPhone 5S, the Ad was started most of the times (not always) but freezed at the beginning of the Ad…

Three different problems with Ads in one week, I’m begiinning to think there’s something going on behind the scenes, perhaps a major Update or something?

If you have an Android device, plug it in to your PC and select Buld And Run from Build Settings, your App will run on device in a few minutes…

In Nox, navigate to System settings > Property settings and try to select another device…

If you’re using Unity 5.5 or later, you can enable the Ads from the Services window, you don’t need to use the Unity Ads plugin anymore, it’s easier to work with, you don’t have to initialize anything, Plug and Play…

Cheers!

yeah i did test it on a device same probleme !

hey t tried to enable ads from the service but UnityEngine.Advertissment wont work unless i add the plugin !

Your code might have some issues, why don’t you follow the guidelines for showing the ad?
Add an event on the Button to show your Ad with code like this:

public void ShowAd () {
        if (Advertisement.IsReady("rewardedVideo")) {
            var options = new ShowOptions { resultCallback = HandleShowResult };
            Advertisement.Show("rewardedVideo", options);
        }
    }
 
    private void HandleShowResult(ShowResult result) {
        switch (result) {
        case ShowResult.Finished:
            // Code to Handle if Ad is Showed...
            break;
        case ShowResult.Skipped:
            // Code to Handle if Ad is Skipped...
            break;
        case ShowResult.Failed:
            // Code to Handle if Ad Failed...
            break;
        }
    }

Unity Instructions are clear, you should do something similar, I use almost the same code on several locations and it works perfect on device with iOS, Android and Nox Emulator…

Cheers!

i think its the same just my code without adding an eventclick also the button must be enabled when the ad is ready but its never ready that why always on the device the button is disabled ; and one more think why ads package wont work from the window service ?
and thank you

finaly the probleme solved
So this how i managed to fixe it :

  • exit Unity

  • delete ProjectSettings/UnityConnectSettings.asset

  • delete Library folder

  • open project in Unity and configure Services accordingly the probleme was in the unity ads package