public InterstitialAdPlugin(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod callback) { bool pass = true; try { eventCallback = desc.EventCallback; this.desc = desc; if (!desc.UseClassicGUI) { // Create Ad Canvas adCanvas = new GameObject("Editor Interstitial Ad"); GameObject.DontDestroyOnLoad(adCanvas); adCanvas.AddComponent<RectTransform>(); var canvas = adCanvas.AddComponent<Canvas>(); canvas.renderMode = RenderMode.ScreenSpaceOverlay; canvas.sortingOrder = desc.UnityUI_SortIndex; adCanvas.AddComponent<CanvasScaler>(); adCanvas.AddComponent<GraphicRaycaster>(); adCanvas.SetActive(false); // Create ad var ad = new GameObject("AdButtonImage"); ad.transform.parent = adCanvas.transform; adRect = ad.AddComponent<RectTransform>(); var image = ad.AddComponent<Image>(); image.sprite = Resources.Load<Sprite>("Reign/Ads/DemoInterstitialAd"); image.preserveAspect = false; var button = ad.AddComponent<Button>(); button.onClick.AddListener(adClicked); adRect.anchorMin = new Vector2(.1f, .1f); adRect.anchorMax = new Vector2(.9f, .9f); adRect.offsetMin = Vector2.zero; adRect.offsetMax = Vector2.zero; // close box var closeBox = new GameObject("AdButtonImage"); closeBox.transform.parent = ad.transform; adRect = closeBox.AddComponent<RectTransform>(); image = closeBox.AddComponent<Image>(); image.sprite = Resources.Load<Sprite>("Reign/Ads/CloseBox"); image.preserveAspect = false; button = closeBox.AddComponent<Button>(); button.onClick.AddListener(adClosed); adRect.anchorMin = new Vector2(.9f, .9f); adRect.anchorMax = new Vector2(1, 1); adRect.offsetMin = Vector2.zero; adRect.offsetMax = Vector2.zero; } } catch (Exception e) { Debug.LogError(e.Message); pass = false; } if (callback != null) callback(pass); }
private async void init(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { bool pass = true; try { eventCallback = desc.EventCallback; unitID = desc.WP8_AdDuplex_UnitID; testing = desc.Testing; } catch (Exception e) { Debug.LogError(e.Message); pass = false; } if (!initialized && pass) { initialized = true; await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, delegate() { AdDuplexClient.Initialize(desc.WP8_AdDuplex_ApplicationKey); UnityEngine.WSA.Application.InvokeOnAppThread(()=> { if (createdCallback != null) createdCallback(pass); }, false); }); } else { if (createdCallback != null) createdCallback(pass); } }
/// <summary> /// Dumy constructor. /// </summary> /// <param name="desc"></param> /// <param name="createdCallback"></param> public Dumy_InterstitialAdPlugin(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { eventCallback = desc.EventCallback; if (createdCallback != null) { createdCallback(true); } }
void Start() { singleton = this; // bind button events CacheAdButton.Select(); CacheAdButton.onClick.AddListener(cacheAdClicked); ShowAdButton.onClick.AddListener(showAdClicked); BackButton.onClick.AddListener(backClicked); // make sure we don't init the same Ad twice if (created) { return; } created = true; // create add var desc = new InterstitialAdDesc(); // Global desc.Testing = true; desc.EventCallback = eventCallback; desc.UseClassicGUI = false; desc.GUIOverrideEnabled = false; desc.UnityUI_SortIndex = 1001; // WinRT (Windows 8.0 & 8.1) desc.WinRT_AdAPI = InterstitialAdAPIs.AdDuplex; // NOTE: If building for WP 8.1 or Universal targets this value is used. All other WinRT values or used for Win8 // NOTE: Currently no Win8 interstisial API are supported. // WP8 (Windows Phone 8.0 & 8.1) desc.WP8_AdAPI = InterstitialAdAPIs.AdMob; // NOTE: If building for WP 8.1 or Universal targets this value is NOT used (Use the WinRT value instead). All other WP8 values are still used for WP 8.0, 8.1 and Universal. desc.WP8_AdMob_UnitID = ""; // NOTE: Must set event for testing desc.WP8_AdDuplex_ApplicationKey = ""; // NOTE: Must set event for testing desc.WP8_AdDuplex_UnitID = ""; // NOTE: Must set event for testing // iOS desc.iOS_AdAPI = InterstitialAdAPIs.AdMob; desc.iOS_AdMob_UnitID = ""; // NOTE: Must set event for testing // Android #if AMAZON desc.Android_AdAPI = InterstitialAdAPIs.Amazon; #else desc.Android_AdAPI = InterstitialAdAPIs.AdMob; #endif desc.Android_AdMob_UnitID = ""; // NOTE: Must set event for testing desc.Android_Amazon_ApplicationKey = ""; // NOTE: Must set event for testing // create ad ad = InterstitialAdManager.CreateAd(desc, createdCallback); }
public Amazon_InterstitialAdPlugin_Android(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { this.createdCallback = createdCallback; try { eventCallback = desc.EventCallback; native = new AndroidJavaClass("com.reignstudios.reignnativeamazon.Amazon_InterstitialAdNative"); id = Guid.NewGuid().ToString(); native.CallStatic("CreateAd", desc.Android_Amazon_ApplicationKey, desc.Testing, id); } catch (Exception e) { Debug.LogError(e.Message); if (createdCallback != null) createdCallback(false); } }
public AdMob_InterstitialAdPlugin_Native(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { bool pass = true; try { eventCallback = desc.EventCallback; unitID = desc.WP8_AdMob_UnitID; testing = desc.Testing; } catch (Exception e) { Debug.LogError(e.Message); pass = false; } if (createdCallback != null) createdCallback(pass); }
public DFP_InterstitialAdPlugin_iOS (InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod callback) { bool pass = true; try { eventCallback = desc.EventCallback; native = DFP_Interstitial_InitAd(desc.Testing); DFP_Interstitial_CreateAd(native, desc.iOS_DFP_UnitID); } catch (Exception e) { Debug.LogError(e.Message); pass = false; } if (callback != null) callback(pass); }
void Start() { // bind button events ShowAdButton.Select(); ShowAdButton.onClick.AddListener(showAdClicked); BackButton.onClick.AddListener(backClicked); // make sure we don't init the same Ad twice if (created) { return; } created = true; // create add var desc = new InterstitialAdDesc(); // Global desc.Testing = true; desc.EventCallback = eventCallback; desc.UseClassicGUI = false; desc.GUIOverrideEnabled = false; desc.UnityUI_SortIndex = 1001; // WP8 desc.WP8_AdAPI = InterstitialAdAPIs.AdMob; desc.WP8_AdMob_UnitID = ""; // NOTE: Must set event for testing // iOS desc.iOS_AdAPI = InterstitialAdAPIs.AdMob; desc.iOS_AdMob_UnitID = ""; // NOTE: Must set event for testing // Android #if AMAZON desc.Android_AdAPI = InterstitialAdAPIs.Amazon; #else desc.Android_AdAPI = InterstitialAdAPIs.AdMob; #endif desc.Android_AdMob_UnitID = ""; // NOTE: Must set event for testing desc.Android_Amazon_ApplicationKey = ""; // NOTE: Must set event for testing // create ad ad = InterstitialAdManager.CreateAd(desc, createdCallback); }
public Amazon_InterstitialAdPlugin_Android(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { this.createdCallback = createdCallback; try { eventCallback = desc.EventCallback; native = new AndroidJavaClass("com.reignstudios.reignnative.Amazon_InterstitialAdNative"); id = Guid.NewGuid().ToString(); native.CallStatic("CreateAd", desc.Android_Amazon_ApplicationKey, desc.Testing, id); } catch (Exception e) { Debug.LogError(e.Message); if (createdCallback != null) { createdCallback(false); } } }
private async void init(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { bool pass = true; try { eventCallback = desc.EventCallback; unitID = desc.WP8_AdDuplex_UnitID; testing = desc.Testing; } catch (Exception e) { Debug.LogError(e.Message); pass = false; } if (!initialized && pass) { initialized = true; await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, delegate() { AdDuplexClient.Initialize(desc.WP8_AdDuplex_ApplicationKey); ReignServices.InvokeOnUnityThread(delegate { if (createdCallback != null) { createdCallback(pass); } }); }); } else { ReignServices.InvokeOnUnityThread(delegate { if (createdCallback != null) { createdCallback(pass); } }); } }
public AdMob_InterstitialAdPlugin_iOS (InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod callback) { #if !IOS_DISABLE_GOOGLE_ADS bool pass = true; try { eventCallback = desc.EventCallback; native = AdMob_Interstitial_InitAd(desc.Testing); AdMob_Interstitial_CreateAd(native, desc.iOS_AdMob_UnitID); } catch (Exception e) { Debug.LogError(e.Message); pass = false; } if (callback != null) callback(pass); #endif }
public AdMob_InterstitialAdPlugin_Native(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { bool pass = true; try { eventCallback = desc.EventCallback; unitID = desc.WP8_AdMob_UnitID; testing = desc.Testing; } catch (Exception e) { Debug.LogError(e.Message); pass = false; } if (createdCallback != null) { createdCallback(pass); } }
public DFP_InterstitialAdPlugin_iOS(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod callback) { bool pass = true; try { eventCallback = desc.EventCallback; native = DFP_Interstitial_InitAd(desc.Testing); DFP_Interstitial_CreateAd(native, desc.iOS_DFP_UnitID); } catch (Exception e) { Debug.LogError(e.Message); pass = false; } if (callback != null) { callback(pass); } }
public AdMob_InterstitialAdPlugin_iOS(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod callback) { #if !IOS_DISABLE_GOOGLE_ADS bool pass = true; try { eventCallback = desc.EventCallback; native = AdMob_Interstitial_InitAd(desc.Testing); AdMob_Interstitial_CreateAd(native, desc.iOS_AdMob_UnitID); } catch (Exception e) { Debug.LogError(e.Message); pass = false; } if (callback != null) { callback(pass); } #endif }
public AdMob_InterstitialAdPlugin_WP8(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { InitNative(this, desc, createdCallback); }
public AdDuplex_InterstitialAdPlugin_Native(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { init(desc, createdCallback); }
public AdDuplex_InterstitialAdPlugin_WinRT(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { InitNative(this, desc, createdCallback); }
public InterstitialAdPlugin(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod callback) { bool pass = true; try { eventCallback = desc.EventCallback; this.desc = desc; if (!desc.UseClassicGUI) { // Create Ad Canvas adCanvas = new GameObject("Editor Interstitial Ad"); GameObject.DontDestroyOnLoad(adCanvas); adCanvas.AddComponent <RectTransform>(); var canvas = adCanvas.AddComponent <Canvas>(); canvas.renderMode = RenderMode.ScreenSpaceOverlay; canvas.sortingOrder = desc.UnityUI_SortIndex; adCanvas.AddComponent <CanvasScaler>(); adCanvas.AddComponent <GraphicRaycaster>(); adCanvas.SetActive(false); // Create ad var ad = new GameObject("AdButtonImage"); ad.transform.parent = adCanvas.transform; adRect = ad.AddComponent <RectTransform>(); var image = ad.AddComponent <Image>(); image.sprite = Resources.Load <Sprite>("Reign/Ads/DemoInterstitialAd"); image.preserveAspect = false; var button = ad.AddComponent <Button>(); button.onClick.AddListener(adClicked); adRect.anchorMin = new Vector2(.1f, .1f); adRect.anchorMax = new Vector2(.9f, .9f); adRect.offsetMin = Vector2.zero; adRect.offsetMax = Vector2.zero; // close box var closeBox = new GameObject("AdButtonImage"); closeBox.transform.parent = ad.transform; adRect = closeBox.AddComponent <RectTransform>(); image = closeBox.AddComponent <Image>(); image.sprite = Resources.Load <Sprite>("Reign/Ads/CloseBox"); image.preserveAspect = false; button = closeBox.AddComponent <Button>(); button.onClick.AddListener(adClosed); adRect.anchorMin = new Vector2(.9f, .9f); adRect.anchorMax = new Vector2(1, 1); adRect.offsetMin = Vector2.zero; adRect.offsetMax = Vector2.zero; } } catch (Exception e) { Debug.LogError(e.Message); pass = false; } if (callback != null) { callback(pass); } }
/// <summary> /// Used by the Reign plugin. /// </summary> /// <param name="desc">The Ad desc.</param> /// <param name="callback">The callback fired when done.</param> /// <returns>Returns Ad plugin interface</returns> public static IInterstitialAdPlugin New(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod callback) { #if DISABLE_REIGN return new Dumy_InterstitialAdPlugin(desc, callback); #elif UNITY_EDITOR return new InterstitialAdPlugin(desc, callback); #elif UNITY_WP8 if (desc.WP8_AdAPI == InterstitialAdAPIs.None) return new Dumy_InterstitialAdPlugin(desc, callback); else if (desc.WP8_AdAPI == InterstitialAdAPIs.AdMob) return new AdMob_InterstitialAdPlugin_WP8(desc, callback); else throw new Exception("Unsuported WP8_AdAPI: " + desc.WP8_AdAPI); #elif UNITY_METRO if (desc.WinRT_AdAPI == InterstitialAdAPIs.AdDuplex) return new AdDuplex_InterstitialAdPlugin_WinRT(desc, callback); else throw new Exception("Unsuported WinRT_AdAPI: " + desc.WinRT_AdAPI); #elif UNITY_IOS if (desc.iOS_AdAPI == InterstitialAdAPIs.None) return new Dumy_InterstitialAdPlugin(desc, callback); else if (desc.iOS_AdAPI == InterstitialAdAPIs.AdMob) return new AdMob_InterstitialAdPlugin_iOS(desc, callback); else if (desc.iOS_AdAPI == InterstitialAdAPIs.DFP) return new DFP_InterstitialAdPlugin_iOS(desc, callback); else throw new Exception("Unsuported iOS_AdAPI: " + desc.iOS_AdAPI); #elif UNITY_ANDROID if (desc.Android_AdAPI == InterstitialAdAPIs.None) return new Dumy_InterstitialAdPlugin(desc, callback); else if (desc.Android_AdAPI == InterstitialAdAPIs.AdMob) return new AdMob_InterstitialAdPlugin_Android(desc, callback); else if (desc.Android_AdAPI == InterstitialAdAPIs.DFP) return new DFP_InterstitialAdPlugin_Android(desc, callback); else if (desc.Android_AdAPI == InterstitialAdAPIs.Amazon) return new Amazon_InterstitialAdPlugin_Android(desc, callback); else throw new Exception("Unsuported Android_AdAPI: " + desc.Android_AdAPI); #else return new Dumy_InterstitialAdPlugin(desc, callback); #endif }
/// <summary> /// Used by the Reign plugin. /// </summary> /// <param name="desc">The Ad desc.</param> /// <param name="callback">The callback fired when done.</param> /// <returns>Returns Ad plugin interface</returns> public static IInterstitialAdPlugin New(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod callback) { #if DISABLE_REIGN return(new Dumy_InterstitialAdPlugin(desc, callback)); #elif UNITY_EDITOR return(new InterstitialAdPlugin(desc, callback)); #elif UNITY_WP8 if (desc.WP8_AdAPI == InterstitialAdAPIs.None) { return(new Dumy_InterstitialAdPlugin(desc, callback)); } else if (desc.WP8_AdAPI == InterstitialAdAPIs.AdMob) { return(new AdMob_InterstitialAdPlugin_WP8(desc, callback)); } else { throw new Exception("Unsuported WP8_AdAPI: " + desc.WP8_AdAPI); } #elif UNITY_METRO if (desc.WinRT_AdAPI == InterstitialAdAPIs.AdDuplex) { return(new AdDuplex_InterstitialAdPlugin_WinRT(desc, callback)); } else { throw new Exception("Unsuported WinRT_AdAPI: " + desc.WinRT_AdAPI); } #elif UNITY_IOS if (desc.iOS_AdAPI == InterstitialAdAPIs.None) { return(new Dumy_InterstitialAdPlugin(desc, callback)); } else if (desc.iOS_AdAPI == InterstitialAdAPIs.AdMob) { return(new AdMob_InterstitialAdPlugin_iOS(desc, callback)); } else if (desc.iOS_AdAPI == InterstitialAdAPIs.DFP) { return(new DFP_InterstitialAdPlugin_iOS(desc, callback)); } else { throw new Exception("Unsuported iOS_AdAPI: " + desc.iOS_AdAPI); } #elif UNITY_ANDROID if (desc.Android_AdAPI == InterstitialAdAPIs.None) { return(new Dumy_InterstitialAdPlugin(desc, callback)); } else if (desc.Android_AdAPI == InterstitialAdAPIs.AdMob) { return(new AdMob_InterstitialAdPlugin_Android(desc, callback)); } else if (desc.Android_AdAPI == InterstitialAdAPIs.DFP) { return(new DFP_InterstitialAdPlugin_Android(desc, callback)); } else if (desc.Android_AdAPI == InterstitialAdAPIs.Amazon) { return(new Amazon_InterstitialAdPlugin_Android(desc, callback)); } else { throw new Exception("Unsuported Android_AdAPI: " + desc.Android_AdAPI); } #else return(new Dumy_InterstitialAdPlugin(desc, callback)); #endif }
/// <summary> /// Dumy constructor. /// </summary> /// <param name="desc"></param> /// <param name="createdCallback"></param> public Dumy_InterstitialAdPlugin(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { eventCallback = desc.EventCallback; if (createdCallback != null) createdCallback(true); }