Admob Unity Plugin API
class list
public class Admob
the main class of Admob Unity Plugin,never new Admob ,just call Admob.Instance() to get admob intance.
-
public delegate void AdmobEventHandler(string eventName, string msg);
admob event delegate define -
public event AdmobEventHandler bannerEventHandler;
delegate to handler admob banner event, -
public event AdmobEventHandler interstitialEventHandler;
delegate to handler admob interstitial event -
public static Admob Instance()
Method to get Admob unique instance -
public void initSDK(AdProperties admob_properties)
init admob ID and admob properties is format ca-app-pub-27960468906xxx~xxxx67388 got from apps.admob.com must config in Info.plist or manifest.xml -
public void showBannerAbsolute(string admob_banner_id,AdSize size, int x, int y)
show admob at absolute position,size can been any const of AdSize such as AdSize.Banner -
public void showBannerRelative(string admob_banner_id,AdSize size, int position, int marginY)
show admob at relative position,position can been any const of AdPosition, size can been any const of AdSize such as AdSize.BANNER -
public void removeBanner(string bannername="defaultBannerName")
remove and hide admob banner ad -
public void loadInterstitial(string interstitial_id)
load admob Interstitial,this will send a ad load request,interstitialEventHandler will been called when load success or fail.
Interstitial will not show auto after load success,So you need to call showInterstitial at right time -
public bool isInterstitialReady()
Detecting whether the ad has finished loading,if Interstitial is loaded success will get true -
public void showInterstitial()
show Interstitial,call this after Interstitial loaded success only
public class AdmobEvent
Admob Event Type
-
public static readonly string onAdLoaded = "onAdLoaded";
Admob Ad loaded success -
public static readonly string onAdFailedToLoad = "onAdFailedToLoad";
Admob Ad load fail -
public static readonly string onAdOpened = "onAdOpened";
Admob Ad is show and opened -
public static readonly string adViewWillDismissScreen = "adViewWillDismissScreen";
Admob Ad will close and dismiss screen -
public static readonly string onAdClosed = "onAdClosed";
Admob Ad is closed -
public static readonly string onAdLeftApplication = "onAdLeftApplication";
Admob Ad is touched and will left application -
public static readonly string onVideoUnmute = "onVideoUnmute";
Admob Video is Unmuted -
public static readonly string onVideoMute = "onVideoMute";
Admob Video is muted -
public static readonly string onVideoEnd = "onVideoEnd";
Admob Video play end -
public static readonly string onVideoPause = "onVideoPause";
Admob Video play paused -
public static readonly string onVideoPlay = "onVideoPlay";
Admob Video playing -
public static readonly string onVideoStart = "onVideoStart";
Admob Video play started -
public static readonly string onNativeAdLoaded = "onNativeAdLoaded";
Admob Native Ads loaded
public class AdPosition
Admob Banner Ad Relative Position const
public static readonly int TOP_LEFT = 1;public static readonly int TOP_CENTER = 2;public static readonly int TOP_RIGHT = 3;public static readonly int MIDDLE_LEFT = 4;public static readonly int MIDDLE_CENTER = 5;public static readonly int MIDDLE_RIGHT = 6;public static readonly int BOTTOM_LEFT = 7;public static readonly int BOTTOM_CENTER = 8;public static readonly int BOTTOM_RIGHT = 9;
public class AdSize
Admob Banner Ad Size define
-
public static readonly AdSize BANNER = new AdSize(320, 50);
banner of size 320x50 -
public static readonly AdSize MEDIUM_RECTANGLE = new AdSize(300, 250);
banner of size 300x250 -
public static readonly AdSize FULL_BANNER = new AdSize(468, 60);
banner of size 468x60 -
public static readonly AdSize LEADERBOARD = new AdSize(728, 90);
banner of size 728x90 -
public static readonly AdSize WIDE_SKYSCRAPER = new AdSize(120,600);
banner of size 120x600 -
public static readonly AdSize SMART_BANNER = new AdSize(-1,-2);
smart banner -
public AdSize(int width, int height)
define a ad size type -
public int Width
return ad size width value -
public int Height
return ad size height value