Hey guys,
im quiet new to admobs and am struggling to put up a simple banner ad due to many tutorials, but none of them are understandale.
I just want to put up a basic banner ad to the top left of the screen but am unable to. need help.
thank you in advance…
Download:
Import:
Open your project in the Unity editor. Select Assets > Import Package > Custom Package and find the GoogleMobileAdsPlugin.unitypackage file you downloaded.
3.Add script(Assets > Create > C# Script):
using UnityEngine;
using GoogleMobileAds.Api;
public class AdManager : MonoBehaviour
{
public string AndroidID = "ca-app-pub-3940256099942544/6300978111";
// Use this for initialization
void Start()
{
DontDestroyOnLoad(this);
this.RequestBanner();
}
private void RequestBanner()
{
#if UNITY_EDITOR
string adUnitId = "unused";
#elif UNITY_ANDROID
string adUnitId = AndroidID;
#else
string adUnitId = "unexpected_platform";
#endif
// Create a banner at the top of the screen.
BannerView bannerView = new BannerView(adUnitId, AdSize.SmartBanner, AdPosition.Top);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the banner with the request.
bannerView.LoadAd(request);
}
}
P.S. playing by Unity Editor will not be show the ads.