Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Monetization 3.3.0 Issues

Discussion in 'Package Manager' started by SoloOutlaw, Nov 5, 2019.

  1. SoloOutlaw

    SoloOutlaw

    Joined:
    Feb 29, 2016
    Posts:
    11
    First of all when you install Monetization 3.3.0 it lists duplicate errors.

    I am now using the Package Manager to update in my project.

    So I remove Unity Ads and started over which appeared sort it.

    So maybe others are having the same problem.

    Secondly

    I get the following error just after I view a rewardedVideo in test.


    MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    GameController.OnUnityAdsDidFinish (System.String placementId, UnityEngine.Advertisements.ShowResult showResult) (at Assets/Scripts/GameController.cs:1533)
    UnityEngine.Advertisements.Platform+<>c__DisplayClass31_1.<Initialize>b__2 (UnityEngine.Advertisements.CallbackExecutor execute) (at Library/PackageCache/com.unity.ads@3.3.1/Runtime/Advertisement/Platform.cs:128)
    UnityEngine.Advertisements.CallbackExecutor.Update () (at Library/PackageCache/com.unity.ads@3.3.1/Runtime/Advertisement/CallbackExecutor.cs:25)

    It's referring to my Lucky Dip Panel.

    This is what I click directly beforehand to activate the advert.

    Now everything is fine until I actually pause my game and return to start menu when this panel is showing.

    I have checked for null states throughout my code and the Lucky Dip Panel always contains something.

    But as soon as it gets to the Finished Listener code it mysteriously has been destroyed.

    Is this a BUG in monetization and is still holding onto data.

    Finally when I upload to Android it works first time issuing me a reward but after that it just must kick out.

    Also the isReady Listener never displays my Debug.log("IsReady").

    Which is odd because I call the isReady function before the Show.

    Can anyone help.
     
  2. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,302
    @SoloOutlaw

    Which version of Unity are you using? Typically, duplicate errors happen when the Ads SDK is installed multiple times. If you install via the Asset Store, then you do not need the package from the Services window or Package Manager.

    https://forum.unity.com/threads/how...ge-package-manager-or-services-window.699005/

    Would you be able to post the ads portion of your GameController script?
     
  3. SoloOutlaw

    SoloOutlaw

    Joined:
    Feb 29, 2016
    Posts:
    11
    using UnityEngine;
    using UnityEngine.UI;
    using System.Collections;
    using UnityEngine.EventSystems;
    using UnityEngine.Advertisements;
    public class GameController : MonoBehaviour, IUnityAdsListener
    {

    ---------------------------------------------

    void Awake()
    {

    Advertisement.AddListener(this);
    }

    ---------------------------------------------------

    public static void UnityAdsInitialise() <CALLED WHEN GAMES STARTS
    {
    // Debug.Log("Initialised");
    string gameId = "-------"; //Play Store
    bool testMode = true; //Set to False once live
    Advertisement.Initialize(gameId, testMode);

    }
    ----------------------------------------------------

    public void LuckyDipPanelPressed()
    {
    if (luckyDipPlayOnce)
    {
    luckyDipPanel.SetActive(false);
    luckyDipPanelShadow.SetActive(false);
    return;
    }
    Debug.Log("2" + luckyDipPanel); <<< THE VALUE HAS VALiD CONTENT
    if (Advertisement.IsReady("rewardedVideo"))
    {
    Advertisement.Show("rewardedVideo"); >>>>GOES TO LISTENER
    }
    else
    {
    recieveText.text = "GIFT Unavailable";
    luckyDipPanel.transform.Find("NowLetsDriveText").gameObject.SetActive(true);
    luckyDipPlayOnce = true;

    }



    }
    ----------------------------------------------------


    // Implement IUnityAdsListener interface methods:
    public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
    {
    if (placementId == "rewardedVideo")

    // Define conditional logic for each ad completion status:
    if ((showResult == ShowResult.Finished) && !luckyDipPlayOnce)
    {
    //Debug.Log("4"+luckyDipPanel); Would throw up ERROR - Gameobject Destroyed

    // Reward the user for watching the ad to completion.
    luckyDipPanel.transform.Find("NowLetsDriveText").gameObject.SetActive(true);
    recieveText.text = "You have recieved the following GIFT";
    int randomGift = Random.Range(0, 3);
    if (randomGift == 0)
    //helmet
    {
    SoundEffectManager.PlaySound("HelmetPickUp");
    joeyHelmet.SetActive(true);
    helmetWorn = true;
    helmetDamage = 0;
    DisplayHelmetDamage();
    miniHelmetDamageText.gameObject.SetActive(true);
    miniHelmetDamageHeader.gameObject.SetActive(true);
    helmetExists = true;
    carController.miniHelmet.gameObject.SetActive(true);
    luckyDipPanel.transform.Find("coin").gameObject.SetActive(false);
    luckyDipPanel.transform.Find("stopwatch").gameObject.SetActive(false);
    luckyDipPanel.transform.Find("RewardText3").gameObject.SetActive(false);
    luckyDipPanel.transform.Find("RewardText5").gameObject.SetActive(false);
    luckyDipPanel.transform.Find("RewardText4").transform.position += new Vector3(5, 0, 0);
    luckyDipPanel.transform.Find("joeyhelmet").transform.position += new Vector3(5, 0, 0);
    }
    //Extra Time
    if (randomGift == 1)
    {
    SoundEffectManager.PlaySound("BonusStandard");
    IncreaseTime(60);
    luckyDipPanel.transform.Find("coin").gameObject.SetActive(false);
    luckyDipPanel.transform.Find("RewardText5").gameObject.SetActive(false);
    luckyDipPanel.transform.Find("RewardText4").gameObject.SetActive(false);
    luckyDipPanel.transform.Find("joeyhelmet").gameObject.SetActive(false);
    }
    //Extra Points
    if (randomGift == 2)
    {
    SoundEffectManager.PlaySound("CoinPickUp");
    int randomCash = Random.Range(4, 11);
    score += randomCash * 5000;

    newText = luckyDipPanel.transform.Find("RewardText5").GetComponent<Text>();
    newText.text = "£" + (randomCash * 5).ToString() + ",000";
    UpdateScoreText();
    luckyDipPanel.transform.Find("coin").transform.position -= new Vector3(5, 0, 0);
    luckyDipPanel.transform.Find("stopwatch").gameObject.SetActive(false);
    luckyDipPanel.transform.Find("RewardText3").gameObject.SetActive(false);
    luckyDipPanel.transform.Find("RewardText5").transform.position -= new Vector3(5, 0, 0);
    luckyDipPanel.transform.Find("RewardText4").gameObject.SetActive(false);
    luckyDipPanel.transform.Find("joeyhelmet").gameObject.SetActive(false);

    }
    }
    else if (showResult == ShowResult.Skipped)
    {
    // Do not reward the user for skipping the ad.
    recieveText.text = "GIFT denied";
    Debug.Log("The ad was skipped before reaching the end.");

    }
    else if (showResult == ShowResult.Failed)
    {
    recieveText.text = "GIFT Unavailable";
    Debug.Log("The ad failed to be shown.");

    }
    luckyDipPlayOnce = true;
    }
    public void OnUnityAdsReady(string placementId)
    {

    Debug.Log("Advert Ready"); <<<THIS NEVER DISPLAYS
    }
    public void OnUnityAdsDidError(string message)
    {
    // Log the error.
    }
    public void OnUnityAdsDidStart(string placementId)
    {
    // Optional actions to take when the end-users triggers an ad.
    }
     
  4. SoloOutlaw

    SoloOutlaw

    Joined:
    Feb 29, 2016
    Posts:
    11
    Version is Personal 2019.2.5f1
     
  5. SoloOutlaw

    SoloOutlaw

    Joined:
    Feb 29, 2016
    Posts:
    11
    I think I have found a solution.

    void OnDestroy()

    Debug.Log("DestroyAdController");
    myButton.onClick.RemoveListener(ShowRewardedVideo);
    Advertisement.RemoveListener(this);

    I think the active listener stays in memory next time round.