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\com.unity.ads@3.4.4\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\$
  • \$\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 at 19:21
  • \$\begingroup\$ @DMGregory how do I uninstall all the packages? \$\endgroup\$ – Simple coder Mar 15 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 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\$ – Simple coder Mar 15 at 22:21
  • 1
    \$\begingroup\$ So then you installed that distribution as instructed, right? Then what happened? \$\endgroup\$ – DMGregory Mar 16 at 0:14
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.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.