0
\$\begingroup\$

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

\$\endgroup\$
9
  • \$\begingroup\$ This looks like a problem with the package itself. You may want to uninstall all the packages you're using and re-install them one by one to clear up any import errors. \$\endgroup\$
    – DMGregory
    Mar 15, 2020 at 19:21
  • \$\begingroup\$ @DMGregory how do I uninstall all the packages? \$\endgroup\$ Mar 15, 2020 at 21:56
  • 1
    \$\begingroup\$ Don't underestimate your ability to answer your own question with a quick search. Did you run into any specific difficulty removing the package? \$\endgroup\$
    – DMGregory
    Mar 15, 2020 at 22:06
  • \$\begingroup\$ @DMGregory gives me the previous error "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" \$\endgroup\$ Mar 15, 2020 at 22:21
  • 1
    \$\begingroup\$ So then you installed that distribution as instructed, right? Then what happened? \$\endgroup\$
    – DMGregory
    Mar 16, 2020 at 0:14

2 Answers 2

2
\$\begingroup\$

That warning is because you have to use the advertisement package, from the package manager instead of the unity monetization of the asset store, cause it's no longer supported after Unity 2018.3 as the warning says.

\$\endgroup\$
0
\$\begingroup\$

What worked for me was deleting a "Unity Ads" folder under Assets in the hierarchy. This was not needed since we already had the Advertisements package and since there were conflicts with said package deleting the unneeded folder resolved issue.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .