GreedyGameAds.Instance.LoadBanner("SDK X Banner adUnit");
// To check if Banner is loaded
GreedyGameAds.Instance.bannerAd.IsLoaded
using UnityEngine;
using GreedyGame;
public class GreedyGameAdsDemoScript : MonoBehaviour
{
private void Start()
{
//after Initialize the GreedyGameAds sdk
this.RequestBanner();
}
public void RequestBanner()
{
//Creates standard Adaptive Banner at Top Position
// After loading Banner will be shown automatically
GreedyGameAds.Instance.LoadBanner("SDK X Banner adUnit");
}
}
GreedyGameAds.Instance.DestroyBanner();
public void DestroyBannerAd()
{
GreedyGameAds.Instance.DestroyBanner();
}
GreedyGameAds.Instance.LoadBanner(adUnitId,BannerSize.STANDARD_BANNER,BannerPosition.Bottom);
The table below lists the standard banner sizes.
//Available Banner Sizes
BannerSize.ADAPTIVE_BANNER;//Default BannerSize
BannerSize.STANDARD_BANNER;
BannerSize.LARGE_BANNER;
BannerSize.IAB_MEDIUM_RECTANGLE;
BannerSize.IAB_FULLSIZE_BANNER;
BannerSize.IAB_LEADERBOARD;
Size in dp(WxH) | Description | Availability | BannerSize constant |
320x50 | Standard Banner | Phones and Tablets | STANDARD_BANNER |
320x100 | Large Banner | Phones and Tablets | LARGE_BANNER |
300x250 | IAB Medium Rectangle | Phones and Tablets | IAB_MEDIUM_RECTANGLE |
468x60 | IAB Full-Size Banner | Tablets | IAB_FULLSIZE_BANNER |
728x90 | IAB Leaderboard | Tablets | IAB_LEADERBOARD |
Provided width x Adaptive height | Adaptive banner | Phones and Tablets | ADAPTIVE_BANNER |
// For Top Position
BannerPosition.Top
//For Bottom Position
BannerPosition.Bottom
To further customize the behavior of your ad, you can hook into a number of events in the ad's lifecycle: loading, opening, closing, and so on. Listen for these events by registering a delegate for the appropriate EventHandler, as shown below.
GreedyGameAds.Instance.bannerView.OnBannerAdloaded
GreedyGameAds.Instance.bannerView.OnBannerAdfailed
public void RequestBanner()
{
GreedyGameAds.Instance.LoadBanner("SDK X Banner adUnit");
// Called when an ad request has successfully loaded.
GreedyGameAds.Instance.bannerView.OnBannerAdloaded += this.HandleOnAdLoaded;
// Called when an ad request failed to load.
GreedyGameAds.Instance.bannerView.OnBannerAdfailed+= this.HandleOnAdFailed;
}
public void HandleOnAdLoaded()
{
MonoBehaviour.print("Ad loaded event received");
}
public void HandleOnAdFailed(string error)
{
MonoBehaviour.print("Failed event received with error: " + error);
}