private async void init(AdDesc desc, AdCreatedCallbackMethod createdCallback) #endif { if (WinRTPlugin.AdGrid == null) { if (createdCallback != null) createdCallback(false); return; } #if WINDOWS_PHONE WinRTPlugin.Dispatcher.BeginInvoke(delegate() #else await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, delegate() #endif { bool pass = true; try { adControl = new AdControl(); #if WINDOWS_PHONE || UNITY_WP_8_1 adControl.IsAutoRefreshEnabled = desc.WP8_MicrosoftAdvertising_UseBuiltInRefresh; if (!desc.WP8_MicrosoftAdvertising_UseBuiltInRefresh) { manualRefreshTimer = new DispatcherTimer(); manualRefreshTimer.Interval = TimeSpan.FromSeconds(desc.WP8_MicrosoftAdvertising_RefreshRate); manualRefreshTimer.Tick += timer_Tick; manualRefreshTimer.Start(); } adControl.IsEngagedChanged += adControl_IsEngagedChanged; adControl.AdRefreshed += adControl_AdRefreshed; #else adControl.IsAutoRefreshEnabled = desc.WinRT_MicrosoftAdvertising_UseBuiltInRefresh; if (!desc.WinRT_MicrosoftAdvertising_UseBuiltInRefresh) { manualRefreshTimer = new DispatcherTimer(); manualRefreshTimer.Interval = TimeSpan.FromSeconds(desc.WinRT_MicrosoftAdvertising_RefreshRate); manualRefreshTimer.Tick += timer_Tick; manualRefreshTimer.Start(); } adControl.IsEngagedChanged += adControl_IsEngagedChanged; adControl.AdRefreshed += adControl_AdRefreshed; #endif adControl.ErrorOccurred += adControl_ErrorOccurred; #if WINDOWS_PHONE adControl.SetValue(System.Windows.Controls.Canvas.ZIndexProperty, 98); #else adControl.SetValue(Windows.UI.Xaml.Controls.Canvas.ZIndexProperty, 98); #endif #if WINDOWS_PHONE || UNITY_WP_8_1 adControl.ApplicationId = desc.Testing ? "test_client" : desc.WP8_MicrosoftAdvertising_ApplicationID; adControl.AdUnitId = desc.WP8_MicrosoftAdvertising_UnitID; switch (desc.WP8_MicrosoftAdvertising_AdSize) { case WP8_MicrosoftAdvertising_AdSize.Wide_640x100: adControl.Width = 640; adControl.Height = 100; if (desc.Testing) adControl.AdUnitId = "Image640_100"; break; case WP8_MicrosoftAdvertising_AdSize.Wide_480x80: adControl.Width = 480; adControl.Height = 80; if (desc.Testing) adControl.AdUnitId = "Image480_80"; break; case WP8_MicrosoftAdvertising_AdSize.Wide_320x50: adControl.Width = 320; adControl.Height = 50; if (desc.Testing) adControl.AdUnitId = "Image320_50"; break; case WP8_MicrosoftAdvertising_AdSize.Wide_300x50: adControl.Width = 300; adControl.Height = 50; if (desc.Testing) adControl.AdUnitId = "Image300_50"; break; default: Debug.LogError("AdPlugin: Unsuported Ad size"); break; } #elif UNITY_METRO adControl.ApplicationId = desc.Testing ? "d25517cb-12d4-4699-8bdc-52040c712cab" : desc.WinRT_MicrosoftAdvertising_ApplicationID; adControl.AdUnitId = desc.WinRT_MicrosoftAdvertising_UnitID; switch (desc.WinRT_MicrosoftAdvertising_AdSize) { case WinRT_MicrosoftAdvertising_AdSize.Tall_160x600: adControl.Width = 160; adControl.Height = 600; if (desc.Testing) adControl.AdUnitId = "10043134"; break; case WinRT_MicrosoftAdvertising_AdSize.Tall_300x600: adControl.Width = 300; adControl.Height = 600; if (desc.Testing) adControl.AdUnitId = "10043030"; break; case WinRT_MicrosoftAdvertising_AdSize.Wide_300x250: adControl.Width = 300; adControl.Height = 250; if (desc.Testing) adControl.AdUnitId = "10043008"; break; case WinRT_MicrosoftAdvertising_AdSize.Wide_728x90: adControl.Width = 728; adControl.Height = 90; if (desc.Testing) adControl.AdUnitId = "10042998"; break; case WinRT_MicrosoftAdvertising_AdSize.Square_250x250: adControl.Width = 250; adControl.Height = 250; if (desc.Testing) adControl.AdUnitId = "10043105"; break; default: Debug.LogError("AdPlugin: Unsuported Ad size"); break; } #endif #if WINDOWS_PHONE || UNITY_WP_8_1 setGravity(desc.WP8_MicrosoftAdvertising_AdGravity); #else setGravity(desc.WinRT_MicrosoftAdvertising_AdGravity); #endif eventCallback = desc.EventCallback; WinRTPlugin.AdGrid.Children.Add(adControl); setVisible(desc.Visible); Debug.Log("Created Ad of ApplicationID: " + adControl.ApplicationId + " AdUnitID" + adControl.AdUnitId); } catch (Exception e) { adControl = null; Debug.LogError(e.Message); } ReignServices.InvokeOnUnityThread(delegate { if (createdCallback != null) createdCallback(pass); }); }); }
private async void init(AdDesc desc, AdCreatedCallbackMethod createdCallback) { if (WinRTPlugin.AdGrid == null) { if (createdCallback != null) createdCallback(false); return; } await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, delegate() { bool pass = true; try { adControl = new AdControl(); adControl.AdClick += adControl_Clicked; adControl.AdLoaded += adControl_AdRefreshed; adControl.AdLoadingError += adControl_ErrorOccurred; adControl.AdCovered += adControl_AdCovered; adControl.NoAd += adControl_NoAd; adControl.IsTest = desc.Testing; adControl.CollapseOnError = true; adControl.SetValue(Windows.UI.Xaml.Controls.Canvas.ZIndexProperty, 98); #if UNITY_WP_8_1 adControl.RefreshInterval = desc.WP8_AdDuplex_RefreshRate; adControl.AppKey = desc.WP8_AdDuplex_ApplicationKey; adControl.AdUnitId = desc.WP8_AdDuplex_UnitID; #else adControl.RefreshInterval = desc.WinRT_AdDuplex_RefreshRate; adControl.AppKey = desc.WinRT_AdDuplex_ApplicationKey; adControl.AdUnitId = desc.WinRT_AdDuplex_UnitID; switch (desc.WinRT_AdDuplex_AdSize) { case WinRT_AdDuplex_AdSize.Tall_160x600: adControl.Size = "160x600"; break; case WinRT_AdDuplex_AdSize.Wide_250x125: adControl.Size = "250x125"; break; case WinRT_AdDuplex_AdSize.Wide_292x60: adControl.Size = "292x60"; break; case WinRT_AdDuplex_AdSize.Wide_300x250: adControl.Size = "300x250"; break; case WinRT_AdDuplex_AdSize.Wide_500x130: adControl.Size = "500x130"; break; case WinRT_AdDuplex_AdSize.Wide_728x90: adControl.Size = "728x90"; break; case WinRT_AdDuplex_AdSize.Square_250x250: adControl.Size = "250x250"; break; default: Debug.LogError("AdPlugin: Unsuported Ad size"); break; } #endif #if UNITY_WP_8_1 setGravity(desc.WP8_AdDuplex_AdGravity); #else setGravity(desc.WinRT_AdDuplex_AdGravity); #endif eventCallback = desc.EventCallback; WinRTPlugin.AdGrid.Children.Add(adControl); setVisible(desc.Visible); Debug.Log("Created Ad of AppKey: " + adControl.AppKey + " AdUnitID" + adControl.AdUnitId); } catch (Exception e) { adControl = null; Debug.LogError(e.Message); } UnityEngine.WSA.Application.InvokeOnAppThread(()=> { if (createdCallback != null) createdCallback(pass); }, false); }); }
private async void init(AdDesc desc, AdCreatedCallbackMethod createdCallback) { if (WinRTPlugin.AdGrid == null) { if (createdCallback != null) { createdCallback(false); } return; } await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, delegate() { bool pass = true; try { adControl = new AdControl(); adControl.AdClick += adControl_Clicked; adControl.AdLoaded += adControl_AdRefreshed; adControl.AdLoadingError += adControl_ErrorOccurred; adControl.AdCovered += adControl_AdCovered; adControl.NoAd += adControl_NoAd; adControl.IsTest = desc.Testing; adControl.CollapseOnError = true; adControl.SetValue(Windows.UI.Xaml.Controls.Canvas.ZIndexProperty, 98); #if UNITY_WP_8_1 adControl.RefreshInterval = desc.WP8_AdDuplex_RefreshRate; adControl.AppKey = desc.WP8_AdDuplex_ApplicationKey; adControl.AdUnitId = desc.WP8_AdDuplex_UnitID; #else adControl.RefreshInterval = desc.WinRT_AdDuplex_RefreshRate; adControl.AppKey = desc.WinRT_AdDuplex_ApplicationKey; adControl.AdUnitId = desc.WinRT_AdDuplex_UnitID; switch (desc.WinRT_AdDuplex_AdSize) { case WinRT_AdDuplex_AdSize.Tall_160x600: adControl.Size = "160x600"; break; case WinRT_AdDuplex_AdSize.Wide_250x125: adControl.Size = "250x125"; break; case WinRT_AdDuplex_AdSize.Wide_292x60: adControl.Size = "292x60"; break; case WinRT_AdDuplex_AdSize.Wide_300x250: adControl.Size = "300x250"; break; case WinRT_AdDuplex_AdSize.Wide_500x130: adControl.Size = "500x130"; break; case WinRT_AdDuplex_AdSize.Wide_728x90: adControl.Size = "728x90"; break; case WinRT_AdDuplex_AdSize.Square_250x250: adControl.Size = "250x250"; break; default: Debug.LogError("AdPlugin: Unsuported Ad size"); break; } #endif #if UNITY_WP_8_1 setGravity(desc.WP8_AdDuplex_AdGravity); #else setGravity(desc.WinRT_AdDuplex_AdGravity); #endif eventCallback = desc.EventCallback; WinRTPlugin.AdGrid.Children.Add(adControl); setVisible(desc.Visible); Debug.Log("Created Ad of AppKey: " + adControl.AppKey + " AdUnitID" + adControl.AdUnitId); } catch (Exception e) { adControl = null; Debug.LogError(e.Message); } ReignServices.InvokeOnUnityThread(delegate { if (createdCallback != null) { createdCallback(pass); } }); }); }
private async void init(AdDesc desc, AdCreatedCallbackMethod createdCallback) #endif { if (WinRTPlugin.AdGrid == null) { if (createdCallback != null) { createdCallback(false); } return; } #if WINDOWS_PHONE WinRTPlugin.Dispatcher.BeginInvoke(delegate() #else await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, delegate() #endif { bool pass = true; try { adControl = new AdControl(); #if WINDOWS_PHONE || UNITY_WP_8_1 adControl.IsAutoRefreshEnabled = desc.WP8_MicrosoftAdvertising_UseBuiltInRefresh; if (!desc.WP8_MicrosoftAdvertising_UseBuiltInRefresh) { manualRefreshTimer = new DispatcherTimer(); manualRefreshTimer.Interval = TimeSpan.FromSeconds(desc.WP8_MicrosoftAdvertising_RefreshRate); manualRefreshTimer.Tick += timer_Tick; manualRefreshTimer.Start(); } adControl.IsEngagedChanged += adControl_IsEngagedChanged; adControl.AdRefreshed += adControl_AdRefreshed; #else adControl.IsAutoRefreshEnabled = desc.WinRT_MicrosoftAdvertising_UseBuiltInRefresh; if (!desc.WinRT_MicrosoftAdvertising_UseBuiltInRefresh) { manualRefreshTimer = new DispatcherTimer(); manualRefreshTimer.Interval = TimeSpan.FromSeconds(desc.WinRT_MicrosoftAdvertising_RefreshRate); manualRefreshTimer.Tick += timer_Tick; manualRefreshTimer.Start(); } adControl.IsEngagedChanged += adControl_IsEngagedChanged; adControl.AdRefreshed += adControl_AdRefreshed; #endif adControl.ErrorOccurred += adControl_ErrorOccurred; #if WINDOWS_PHONE adControl.SetValue(System.Windows.Controls.Canvas.ZIndexProperty, 98); #else adControl.SetValue(Windows.UI.Xaml.Controls.Canvas.ZIndexProperty, 98); #endif #if WINDOWS_PHONE || UNITY_WP_8_1 adControl.ApplicationId = desc.Testing ? "test_client" : desc.WP8_MicrosoftAdvertising_ApplicationID; adControl.AdUnitId = desc.WP8_MicrosoftAdvertising_UnitID; switch (desc.WP8_MicrosoftAdvertising_AdSize) { case WP8_MicrosoftAdvertising_AdSize.Wide_640x100: adControl.Width = 640; adControl.Height = 100; if (desc.Testing) { adControl.AdUnitId = "Image640_100"; } break; case WP8_MicrosoftAdvertising_AdSize.Wide_480x80: adControl.Width = 480; adControl.Height = 80; if (desc.Testing) { adControl.AdUnitId = "Image480_80"; } break; case WP8_MicrosoftAdvertising_AdSize.Wide_320x50: adControl.Width = 320; adControl.Height = 50; if (desc.Testing) { adControl.AdUnitId = "Image320_50"; } break; case WP8_MicrosoftAdvertising_AdSize.Wide_300x50: adControl.Width = 300; adControl.Height = 50; if (desc.Testing) { adControl.AdUnitId = "Image300_50"; } break; default: Debug.LogError("AdPlugin: Unsuported Ad size"); break; } #elif UNITY_METRO adControl.ApplicationId = desc.Testing ? "d25517cb-12d4-4699-8bdc-52040c712cab" : desc.WinRT_MicrosoftAdvertising_ApplicationID; adControl.AdUnitId = desc.WinRT_MicrosoftAdvertising_UnitID; switch (desc.WinRT_MicrosoftAdvertising_AdSize) { case WinRT_MicrosoftAdvertising_AdSize.Tall_160x600: adControl.Width = 160; adControl.Height = 600; if (desc.Testing) { adControl.AdUnitId = "10043134"; } break; case WinRT_MicrosoftAdvertising_AdSize.Tall_300x600: adControl.Width = 300; adControl.Height = 600; if (desc.Testing) { adControl.AdUnitId = "10043030"; } break; case WinRT_MicrosoftAdvertising_AdSize.Wide_300x250: adControl.Width = 300; adControl.Height = 250; if (desc.Testing) { adControl.AdUnitId = "10043008"; } break; case WinRT_MicrosoftAdvertising_AdSize.Wide_728x90: adControl.Width = 728; adControl.Height = 90; if (desc.Testing) { adControl.AdUnitId = "10042998"; } break; case WinRT_MicrosoftAdvertising_AdSize.Square_250x250: adControl.Width = 250; adControl.Height = 250; if (desc.Testing) { adControl.AdUnitId = "10043105"; } break; default: Debug.LogError("AdPlugin: Unsuported Ad size"); break; } #endif #if WINDOWS_PHONE || UNITY_WP_8_1 setGravity(desc.WP8_MicrosoftAdvertising_AdGravity); #else setGravity(desc.WinRT_MicrosoftAdvertising_AdGravity); #endif eventCallback = desc.EventCallback; WinRTPlugin.AdGrid.Children.Add(adControl); setVisible(desc.Visible); Debug.Log("Created Ad of ApplicationID: " + adControl.ApplicationId + " AdUnitID" + adControl.AdUnitId); } catch (Exception e) { adControl = null; Debug.LogError(e.Message); } ReignServices.InvokeOnUnityThread(delegate { if (createdCallback != null) { createdCallback(pass); } }); }); }