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); } }
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); }
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> /// 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); }