Skip to content

Instantly share code, notes, and snippets.

@IJEMIN
Last active January 11, 2018 05:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IJEMIN/7178fea1a7abb0d85c013181e837cb24 to your computer and use it in GitHub Desktop.
Save IJEMIN/7178fea1a7abb0d85c013181e837cb24 to your computer and use it in GitHub Desktop.
//Add Symbol "USING_GOOGLE_MOBILE_ADS" to Build Setting after import GoogleMobileAds library from here https://github.com/googleads/googleads-mobile-unity
#if USING_GOOGLE_MOBILE_ADS
using UnityEngine;
//using System.Collections;
using GoogleMobileAds.Api;
public class AdmobBannerLoader : MonoBehaviour {
public string adUnitId;
public string testDeviceId;
// Use this for initialization
void Start () {
AdSize m_adSize = null;
switch (adSize)
{
case AD_SIZE.BANNER:
m_adSize = AdSize.Banner;
break;
case AD_SIZE.IAB_BANNER:
m_adSize = AdSize.IABBanner;
break;
case AD_SIZE.LEADER_BOARD:
m_adSize = AdSize.Leaderboard;
break;
case AD_SIZE.MEDIUM_RECTANGLE:
m_adSize = AdSize.MediumRectangle;
break;
case AD_SIZE.SMART_BANNER:
m_adSize = AdSize.SmartBanner;
break;
}
BannerView bannerView = new BannerView(adUnitId, m_adSize, adPosition);
AdRequest request = new AdRequest.Builder().AddTestDevice(testDeviceId).Build();
bannerView.LoadAd(request);
}
public enum AD_SIZE
{
BANNER, MEDIUM_RECTANGLE, IAB_BANNER, LEADER_BOARD, SMART_BANNER
}
public AD_SIZE adSize = AD_SIZE.SMART_BANNER;
public AdPosition adPosition = AdPosition.Bottom;
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment