Good day,
I already checked and search almost every forum and could not find the answer. My code is below, so if i use the code like this my banner shows when i start the game for the first time. But if i restart the game in my game menu, banner is gone. As i mentioned before this is a problem only happens in Unity editor. In my Android device banner stays so looks like there is no problem, But I am not sure.
So i like to ask 2 questions.
1- Is it okay to use my code, since its only Unity Editor problem, and It works as expected in my device(It request only 1 banner and I can use that banner until I quit).
2- From what I understand, my script below makes 1 banner dummy when I start the game for the first time. And in the hiyerarchy my code('GoogleMobileAdsDemoScript ') goes under DontDestroyOnLoad, but banner dummy does not. Thats why when I restart the scene dummy disappears. Dummy created from below script is not persistent , but the script is persistent. So what I am trying to ask, is that dummy ad meant to be persistent in Editor or not ? Lets say if i create 1 dummy banner without singleton and change my scene is it meant to stay in android device even if dummy does not show up in the editor ?
public class GoogleMobileAdsDemoScript : MonoBehaviour
{
private BannerView bannerView;
public static GoogleMobileAdsDemoScript instance;
private void Awake()
{
if (instance == null)
{
instance = this;
DontDestroyOnLoad(this);
}
else
{
Destroy(gameObject);
return;
}
}
public void Start()
{
this.RequestBanner();
}
private void RequestBanner()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-3940256099942544/6300978111";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-3940256099942544/2934735716";
#else
string adUnitId = "unexpected_platform";
#endif
// Create a 320x50 banner at the top of the screen.
bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Top);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the banner with the request.
bannerView.LoadAd(request);
}
}