Question by
KristianGrytdal · Feb 05, 2017 at 10:11 PM ·
c#erroradmobnullreference
NullReferenceException: Object reference not set to an instance of an object Problem!
I have error that says: "NullReferenceException: Object reference not set to an instance of an object GPGMenu.Start()(at assets/Script/AdBanner/GPGMenu.cs:15)" It's in a script that I have to show a banner ad on my app. Does anybody know how to fix it ? Thanks in advance!
using UnityEngine; using System.Collections; using GooglePlayGames; using UnityEngine.SocialPlatforms;
public class GPGMenu : MonoBehaviour {
private const string AD_UNIT_ID = "ca-app-pub-6064982889333937/2223770401";
private AdMobPlugin admob;
// Use this for initialization
public void Start ()
{
admob = GetComponent<AdMobPlugin>();
admob.CreateBanner (AD_UNIT_ID, AdMobPlugin.AdSize.SMART_BANNER, true);
admob.RequestAd ();
admob.ShowBanner ();
Debug.Log ("Loaded ad");
}
// Update is called once per frame
void Update () {
}
public void ShowBannerbutton()
{
admob.ShowBanner ();
Debug.Log ("Show ad");
}
}
Comment