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> /// Use to create multiple Ads. /// </summary> /// <param name="descs">Your AdDesc settings.</param> /// <param name="createdCallback">The callback that fires when done.</param> /// <returns>Returns array of Ad objects</returns> public static InterstitialAd[] CreateAd(InterstitialAdDesc[] descs, InterstitialAdCreatedCallbackMethod createdCallback) { if (creatingAds) { Debug.LogError("You must wait for the last interstitial ads to finish being created!"); if (createdCallback != null) { createdCallback(false); } return(null); } creatingAds = true; InterstitialAdManager.createdCallback = createdCallback; int startLength = plugins.Count; for (int i = 0; i != descs.Length; ++i) { plugins.Add(InterstitialAdPluginAPI.New(descs[i], async_CreatedCallback)); } var ads = new InterstitialAd[descs.Length]; for (int i = 0, i2 = startLength; i != descs.Length; ++i, ++i2) { ads[i] = new InterstitialAd(plugins[i2]); } return(ads); }
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> /// 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); } }
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); }
/// <summary> /// Use to create a single Ad. /// </summary> /// <param name="desc">Your AdDesc settings.</param> /// <param name="createdCallback">The callback that fires when done.</param> /// <returns>Returns Ad object</returns> public static InterstitialAd CreateAd(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { if (creatingAds) { Debug.LogError("You must wait for the last interstitial ad to finish being created!"); if (createdCallback != null) { createdCallback(false); } return(null); } creatingAds = true; InterstitialAdManager.createdCallback = createdCallback; plugins.Add(InterstitialAdPluginAPI.New(desc, async_CreatedCallback)); return(new InterstitialAd(plugins[plugins.Count - 1])); }
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 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 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> /// 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); }
public AdMob_InterstitialAdPlugin_WP8(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { InitNative(this, desc, createdCallback); }
private static void init_AdMob_InterstitialAdPlugin(AdMob_InterstitialAdPlugin_WP8 plugin, InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { plugin.Native = new AdMob_InterstitialAdPlugin_Native(desc, createdCallback); }
private static void init_AdDuplex_InterstitialAdPlugin(AdDuplex_InterstitialAdPlugin_WinRT plugin, InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { #if UNITY_WP_8_1 && !WINRT_DISABLE_ADDUPLEX_ADS plugin.Native = new AdDuplex_InterstitialAdPlugin_Native(desc, createdCallback); #else plugin.Native = new Dumy_InterstitialAdPlugin(desc, createdCallback); #endif }
private static void init_AdMob_InterstitialAdPlugin(AdMob_InterstitialAdPlugin_WP8 plugin, InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { #if !WINRT_DISABLE_GOOGLE_ADS plugin.Native = new AdMob_InterstitialAdPlugin_Native(desc, createdCallback); #endif }
public AdDuplex_InterstitialAdPlugin_Native(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { init(desc, createdCallback); }
private static void init_AdMob_InterstitialAdPlugin(AdMob_InterstitialAdPlugin_WP8 plugin, InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { #if !WINRT_DISABLE_GOOGLE_ADS plugin.Native = new AdMob_InterstitialAdPlugin_Native(desc, createdCallback); #endif }
public AdDuplex_InterstitialAdPlugin_WinRT(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { InitNative(this, desc, createdCallback); }
public AdDuplex_InterstitialAdPlugin_Native(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { init(desc, createdCallback); }
/// <summary> /// Use to create multiple Ads. /// </summary> /// <param name="descs">Your AdDesc settings.</param> /// <param name="createdCallback">The callback that fires when done.</param> /// <returns>Returns array of Ad objects</returns> public static InterstitialAd[] CreateAd(InterstitialAdDesc[] descs, InterstitialAdCreatedCallbackMethod createdCallback) { if (creatingAds) { Debug.LogError("You must wait for the last interstitial ads to finish being created!"); if (createdCallback != null) createdCallback(false); return null; } creatingAds = true; InterstitialAdManager.createdCallback = createdCallback; int startLength = plugins.Count; for (int i = 0; i != descs.Length; ++i) plugins.Add(InterstitialAdPluginAPI.New(descs[i], async_CreatedCallback)); var ads = new InterstitialAd[descs.Length]; for (int i = 0, i2 = startLength; i != descs.Length; ++i, ++i2) ads[i] = new InterstitialAd(plugins[i2]); return ads; }
private static void init_AdDuplex_InterstitialAdPlugin(AdDuplex_InterstitialAdPlugin_WinRT plugin, InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { #if UNITY_WP_8_1 plugin.Native = new AdDuplex_InterstitialAdPlugin_Native(desc, createdCallback); #else plugin.Native = new Dumy_InterstitialAdPlugin(desc, createdCallback); #endif }
public AdDuplex_InterstitialAdPlugin_WinRT(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { InitNative(this, desc, createdCallback); }
/// <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 }
public AdMob_InterstitialAdPlugin_WP8(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { InitNative(this, desc, createdCallback); }
private static void init_AdMob_InterstitialAdPlugin(AdMob_InterstitialAdPlugin_WP8 plugin, InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { plugin.Native = new AdMob_InterstitialAdPlugin_Native(desc, createdCallback); }
/// <summary> /// Use to create a single Ad. /// </summary> /// <param name="desc">Your AdDesc settings.</param> /// <param name="createdCallback">The callback that fires when done.</param> /// <returns>Returns Ad object</returns> public static InterstitialAd CreateAd(InterstitialAdDesc desc, InterstitialAdCreatedCallbackMethod createdCallback) { if (creatingAds) { Debug.LogError("You must wait for the last interstitial ad to finish being created!"); if (createdCallback != null) createdCallback(false); return null; } creatingAds = true; InterstitialAdManager.createdCallback = createdCallback; plugins.Add(InterstitialAdPluginAPI.New(desc, async_CreatedCallback)); return new InterstitialAd(plugins[plugins.Count-1]); }