Hello everyone,
I have a little problem, everything works good, ads are initialized, unity dashboard is keeping track of my ads, but yesterday ads started not to play their video. You still can watch them, skip them and everything, but their video are not playing. They start and end with a picture from the start of their video…
What can I do?
This is my AdManager:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;
public class AdManager : MonoBehaviour, IUnityAdsInitializationListener
{
[SerializeField] string _androidGameId;
[SerializeField] string _iOSGameId;
[SerializeField] bool _testMode = false;
private string _gameId;
void Awake()
{
DontDestroyOnLoad(this.gameObject);
InitializeAds();
}
public void InitializeAds()
{
_gameId = (Application.platform == RuntimePlatform.IPhonePlayer)
? _iOSGameId
: _androidGameId;
Advertisement.Initialize(_gameId, _testMode, this);
}
public void OnInitializationComplete()
{
Debug.Log("Unity Ads initialization complete.");
}
public void OnInitializationFailed(UnityAdsInitializationError error, string message)
{
Debug.Log($"Unity Ads Initialization Failed: {error.ToString()} - {message}");
}
}
This is how I display the ads:
using UnityEngine;
using UnityEngine.Advertisements;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class RewardedAds : MonoBehaviour, IUnityAdsLoadListener, IUnityAdsShowListener
{
[SerializeField] string _androidAdUnitId = "rewardedVideo";
[SerializeField] string _iOSAdUnitId = "rewardedVideo";
string _adUnitId;
void Awake()
{
_adUnitId = (Application.platform == RuntimePlatform.IPhonePlayer) ?
_iOSAdUnitId :
_androidAdUnitId;
}
private void Start()
{
LoadAd();
}
// Load content to the Ad Unit:
public void LoadAd()
{
// IMPORTANT! Only load content AFTER initialization (in this example, initialization is handled in a different script).
Debug.Log("Loading Ad: " + _adUnitId);
Advertisement.Load(_adUnitId, this);
}
// If the ad successfully loads, add a listener to the button and enable it:
public void OnUnityAdsAdLoaded(string adUnitId)
{
Debug.Log("Ad Loaded: " + adUnitId);
if (adUnitId.Equals(_adUnitId))
{
}
}
// Implement a method to execute when the user clicks the button.
public void ShowAd()
{
// Then show the ad:
Advertisement.Show(_adUnitId, this);
}
// Implement the Show Listener's OnUnityAdsShowComplete callback method to determine if the user gets a reward:
public void OnUnityAdsShowComplete(string adUnitId, UnityAdsShowCompletionState showCompletionState)
{
if (adUnitId.Equals(_adUnitId) && showCompletionState.Equals(UnityAdsShowCompletionState.COMPLETED))
{
// Grant a reward.
// if you are in spin menu wait the ads to be loaded
Scene currentScene = SceneManager.GetActiveScene();
if (currentScene.name == "MainMenu")
{
PlayerInfo.instance.crowns++;
PlayerInfo.instance.SaveGame();
}
// Load another ad:
Advertisement.Load(_adUnitId, this);
}
}
// Implement Load and Show Listener error callbacks:
public void OnUnityAdsFailedToLoad(string adUnitId, UnityAdsLoadError error, string message)
{
Debug.Log($"Error loading Ad Unit {adUnitId}: {error.ToString()} - {message}");
// Use the error details to determine whether to try to load another ad.
}
public void OnUnityAdsShowFailure(string adUnitId, UnityAdsShowError error, string message)
{
Debug.Log($"Error showing Ad Unit {adUnitId}: {error.ToString()} - {message}");
// Use the error details to determine whether to try to load another ad.
}
public void OnUnityAdsShowStart(string adUnitId) { }
public void OnUnityAdsShowClick(string adUnitId) { }
void OnDestroy()
{
// Clean up the button listeners:
//_showAdButton.onClick.RemoveAllListeners();
}
}
EDIT: Also when i turn on Ads on Service panel it stay active for 5-10 seconds and then automatically turning off.
I have IAP Service activated too.
EDIT2: I found that this is happening only when the player is connected to internet using WIFI connection… If player switches do mobile data internet it is working. Please help