I followed this tutorial https://www.youtube.com/watch?v=OElh7wda4Qc in Unity version 2019.3.1f.1 Personal Edition, but I got 6 errors like this in the console, also I updated to version 3.4.4 via the package manager, because it said that the asset store version was not compatible anymore.
Library\PackageCache\[email protected]\Runtime\Monetization\AndroidPlacementContentOperations.cs(55,40): error CS0433: The type 'IUnityLifecycleManager' exists in both 'UnityEngine.Advertisements.Editor, Version=3.4.2.0, Culture=neutral, PublicKeyToken=null' and 'UnityEngine.Advertisements, Version=3.4.2.0, Culture=neutral, PublicKeyToken=null'
This is the code I am using, its the same as the code in the official website, but personalized to my project.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;
using UnityEngine.UI;
public class adsController : MonoBehaviour, IUnityAdsListener
{
public bool testMode = true;
public Button rewardedAd;
private string storeID = "3509232";
private string rewardedVideo = "rewardedVideo";
private void Start()
{
rewardedAd.interactable = Advertisement.IsReady(rewardedVideo);
rewardedAd.onClick.AddListener(ShowRewardedVideo);
Advertisement.Initialize(storeID, testMode);
}
private void Update()
{
}
private void ShowRewardedVideo()
{
Advertisement.Show(rewardedVideo);
}
// Implement IUnityAdsListener interface methods:
public void OnUnityAdsReady(string placementId)
{
// If the ready Placement is rewarded, activate the button:
if (placementId == rewardedVideo)
{
rewardedAd.interactable = true;
}
}
public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
{
// Define conditional logic for each ad completion status:
if (showResult == ShowResult.Finished)
{
// Reward the user for watching the ad to completion.
Debug.Log("Reward");
}
else if (showResult == ShowResult.Skipped)
{
// Do not reward the user for skipping the ad.
Debug.Log("Not Reward");
}
else if (showResult == ShowResult.Failed)
{
Debug.LogWarning("The ad did not finish due to an error.");
}
}
public void OnUnityAdsDidError(string message)
{
// Log the error.
}
public void OnUnityAdsDidStart(string placementId)
{
// Optional actions to take when the end-users triggers an ad.
}
}
EDIT:
Looks like I forgot a line in the code and reinstalling the unity ads package now it runs but still gives this warning.
Please consider upgrading to the Packman Distribution of the Unity Ads SDK. The Asset Store distribution will not longer be supported after Unity 2018.3