Search Unity

Getting error on events of admob. Unity 2019.3.0a5

Discussion in 'Unity Ads & User Acquisition' started by electr1on, Aug 31, 2019.

  1. electr1on

    electr1on

    Joined:
    Mar 21, 2018
    Posts:
    28
    NullReferenceException: Object reference not set to an instance of an object
    AdManager.OnEnable () (at Assets/Scripts/AdManager.cs:40)


    private void OnEnable()
    {
    banner.OnAdLoaded += OnBannerLoaded;
    banner.OnAdFailedToLoad += OnBannerFailedToLoad;
    interstitial.OnAdClosed += OnInterstitialClosed;
    video_OnAdFailedToLoad += OnVideoFailedToLoad;
    video_OnAdClosed += OnVideoClosed;
    video_OnAdRewarded += OnVideoRewarded;
    }
    private void OnDisable()
    {
    banner.OnAdLoaded -= OnBannerLoaded;
    banner.OnAdFailedToLoad -= OnBannerFailedToLoad;
    interstitial.OnAdClosed -= OnInterstitialClosed;
    video_OnAdFailedToLoad -= OnVideoFailedToLoad;
    video_OnAdClosed -= OnVideoClosed;
    video_OnAdRewarded -= OnVideoRewarded;
    }

    I download the plugin form : https://developers.google.com/admob/unity/start
    On my android device the events dont get called

    I hope you will help me

    thanks!
     
  2. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @electr1on

    This error message means that you have a variable somewhere that is null, but you are using it as if has data. Can you check exactly what is happening at line 40 of your AdManager script.

    If the excerpt you provided is around line 40, then I would suspect that the banner variable or the video variable is null and needs to be set.