private static void RaiseActionOnAppThread(Action <WSABannerAdType> action, WSABannerAdType adType) { if (action != null) { AppCallbacks.Instance.InvokeOnAppThread(() => { action(adType); }, false); } }
/// <summary> /// Destroy the banner ad /// </summary> /// <param name="adType">The ad type</param> public static void DestroyAd(WSABannerAdType adType) { if (!_unityEditor) { UnityEngine.WSA.Application.InvokeOnUIThread(() => { _BannerAdDestroy(adType.ToString()); }, false); } }
/// <summary> /// Reconfigure an existing ad /// </summary> /// <param name="adType">The ad type</param> /// <param name="width">Width of the ad</param> /// <param name="height">Height of the ad</param> /// <param name="verticalPlacement">Where should the ad be placed vertically</param> /// <param name="horizontalPlacement">Where should the ad be placed horizontally</param> public static void ReconfigureAd(WSABannerAdType adType, int width, int height, WSAAdVerticalPlacement verticalPlacement, WSAAdHorizontalPlacement horizontalPlacement) { if (!_unityEditor) { UnityEngine.WSA.Application.InvokeOnUIThread(() => { _BannerAdReconfigure(adType.ToString(), width, height, verticalPlacement.ToString(), horizontalPlacement.ToString()); }, false); } }
/// <summary> /// Show or hide the banner ad /// </summary> /// <param name="adType">The ad type</param> /// <param name="visible">Should the ad be visible</param> public static void SetAdVisibility(WSABannerAdType adType, bool visible) { if (!_unityEditor) { UnityEngine.WSA.Application.InvokeOnUIThread(() => { _BannerAdSetVisibility(adType.ToString(), visible); }, false); } }
/// <summary> /// Create a banner ad /// </summary> /// <param name="adType">The ad type</param> /// <param name="width">Width of the ad</param> /// <param name="height">Height of the ad</param> /// <param name="verticalPlacement">Where should the ad be placed vertically</param> /// <param name="horizontalPlacement">Where should the ad be placed horizontally</param> public static void CreatAd(WSABannerAdType adType, int width, int height, WSAAdVerticalPlacement verticalPlacement, WSAAdHorizontalPlacement horizontalPlacement) { if (!_unityEditor) { UnityEngine.WSA.Application.InvokeOnUIThread(() => { if (adType == WSABannerAdType.AdDuplex) { _BannerAdCreate(adType.ToString(), _adDuplexAppId, _adDuplexAdUnitId, width, height, verticalPlacement.ToString(), horizontalPlacement.ToString()); } else if (adType == WSABannerAdType.Microsoft) { _BannerAdCreate(adType.ToString(), _msAppId, _msAdUnitId, width, height, verticalPlacement.ToString(), horizontalPlacement.ToString()); } }, false); } }
/// <summary> /// Initialise the banner ad for the specified provider /// </summary> /// <param name="adType">The ad network to initialise</param> /// <param name="appId">Your apps id</param> /// <param name="adUnitId">Your apps ad unit id</param> public static void Initialise(WSABannerAdType adType, string appId, string adUnitId) { if (!_unityEditor) { switch (adType) { case WSABannerAdType.AdDuplex: _adDuplexAppId = appId; _adDuplexAdUnitId = adUnitId; break; case WSABannerAdType.Microsoft: _msAppId = appId; _msAdUnitId = adUnitId; break; } _BannerAdInitialise(AdRefreshedCallback, ErrorOccurredCallback); } }