Null reference exception while calling methods from Admanager Script. I have done everything but cant sort out that problem. The problem is that when I call the Requestbanner(); and showfullscreenad(); It gives me an error called null reference exception I am getting that error form days and cant sort it out can any one please help me out. I will be really thank for. Peace :) Code of Ad manager: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using GoogleMobileAds.Api; using System; public class AddManagers : MonoBehaviour { public static AddManagers instance; public string AppId; private BannerView bannerView; public string bannerId; private InterstitialAd FulScreenAdd; public string FullScreenId; private void Awake() { if (instance = null) { instance = this; } else { Destroy(this); } } private void Start() { MobileAds.Initialize(AppId); RequestFullScreenAdds(); FulScreenAdd.OnAdClosed += HandlerOnCloased; } public void RequestBanner() { bannerView = new BannerView(bannerId, AdSize.Banner, AdPosition.Top); AdRequest request = new AdRequest.Builder().Build(); bannerView.LoadAd(request); bannerView.Show(); } public void HideBanner() { bannerView.Hide(); } public void RequestFullScreenAdds() { FulScreenAdd = new InterstitialAd(FullScreenId); AdRequest request = new AdRequest.Builder().Build(); FulScreenAdd.LoadAd(request); } public void HandlerOnCloased(object sender, EventArgs args) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); } public void ShowFullScreenAdd() { if(FulScreenAdd.IsLoaded()) { FulScreenAdd.Show(); } else { Debug.Log("Adds are not loaded"); } } } https://ift.tt/eA8V8J
I have done everything but cant sort out that problem. The problem is that when I call the Requestbanner(); and showfullscreenad(); It gives me an error called null reference exception I am getting that error form days and cant sort it out can any one please help me out. I will be really thank for. Peace :) Code of Ad manager: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using GoogleMobileAds.Api; using System; public class AddManagers : MonoBehaviour { public static AddManagers instance; public string AppId; private BannerView bannerView; public string bannerId; private InterstitialAd FulScreenAdd; public string FullScreenId; private void Awake() { if (instance = null) { instance = this; } else { Destroy(this); } } private void Start() { MobileAds.Initialize(AppId); RequestFullScreenAdds(); FulScreenAdd.OnAdClosed += HandlerOnCloased; } public void RequestBanner() { bannerView = new BannerView(bannerId, AdSize.Banner, AdPosition.Top); AdRequest request = new AdRequest.Builder().Build(); bannerView.LoadAd(request); bannerView.Show(); } public void HideBanner() { bannerView.Hide(); } public void RequestFullScreenAdds() { FulScreenAdd = new InterstitialAd(FullScreenId); AdRequest request = new AdRequest.Builder().Build(); FulScreenAdd.LoadAd(request); } public void HandlerOnCloased(object sender, EventArgs args) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); } public void ShowFullScreenAdd() { if(FulScreenAdd.IsLoaded()) { FulScreenAdd.Show(); } else { Debug.Log("Adds are not loaded"); } } }
from GameDev.net https://ift.tt/2TMd3oL
from GameDev.net https://ift.tt/2TMd3oL
ليست هناك تعليقات