Legacy Documentation: Version 5.3
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

ADBannerView

class in UnityEngine.iOS

Description

ADBannerView is a wrapper around the ADBannerView class found in the Apple iAd framework and is only available on iOS.

It provides a view that displays banner advertisements to the user.

using UnityEngine;
using System.Collections;

using ADBannerView = UnityEngine.iOS.ADBannerView;

public class NewBehaviourScript : MonoBehaviour {

private ADBannerView banner = null; void Start() { banner = new ADBannerView(ADBannerView.Type.Banner, ADBannerView.Layout.Top); ADBannerView.onBannerWasClicked += OnBannerClicked; ADBannerView.onBannerWasLoaded += OnBannerLoaded; ADBannerView.onBannerFailedToLoad += OnBannerFailedToLoad; }

void OnBannerClicked() { Debug.Log("Clicked!\n"); }

void OnBannerLoaded() { Debug.Log("Loaded!\n"); banner.visible = true; }

void OnBannerFailedToLoad() { Debug.Log("FAIL!\n"); banner.visible = false; } }

Variables

layoutBanner layout.
loadedChecks if banner contents are loaded.
positionThe position of the banner view.
sizeThe size of the banner view.
visibleBanner visibility. Initially banner is not visible.

Constructors

ADBannerViewCreates a banner view with given type and auto-layout params.

Static Functions

IsAvailableChecks if the banner type is available (e.g. MediumRect is available only starting with ios6).

Delegates

BannerFailedToLoadDelegateWill be fired when banner ad failed to load.
BannerWasClickedDelegateWill be fired when banner was clicked.
BannerWasLoadedDelegateWill be fired when banner loaded new ad.