public void SetGravity(AdGravity gravity) { #if !IOS_DISABLE_GOOGLE_ADS int gravityIndex = convertGravity(gravity); DFP_SetAdGravity(native, gravityIndex); #endif }
public void SetGravity(AdGravity gravity) { if (adView == null) { return; } WinRTPlugin.Dispatcher.BeginInvoke(delegate() { setGravity(gravity); }); }
public async void SetGravity(AdGravity gravity) { if (adControl == null) { return; } await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, delegate() { setGravity(gravity); }); }
private int convertGravity(AdGravity gravity) { int gravityIndex = 0; switch (gravity) { case AdGravity.BottomLeft: gravityIndex = 0; break; case AdGravity.BottomRight: gravityIndex = 1; break; case AdGravity.BottomCenter: gravityIndex = 2; break; case AdGravity.TopLeft: gravityIndex = 3; break; case AdGravity.TopRight: gravityIndex = 4; break; case AdGravity.TopCenter: gravityIndex = 5; break; } return gravityIndex; }
public async void SetGravity(AdGravity gravity) #endif { if (adControl == null) { return; } #if WINDOWS_PHONE WinRTPlugin.Dispatcher.BeginInvoke(delegate() #else await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, delegate() #endif { setGravity(gravity); }); }
private void setGravity(AdGravity gravity) { switch (gravity) { case AdGravity.BottomLeft: adControl.HorizontalAlignment = HorizontalAlignment.Left; adControl.VerticalAlignment = VerticalAlignment.Bottom; break; case AdGravity.BottomRight: adControl.HorizontalAlignment = HorizontalAlignment.Right; adControl.VerticalAlignment = VerticalAlignment.Bottom; break; case AdGravity.BottomCenter: adControl.HorizontalAlignment = HorizontalAlignment.Center; adControl.VerticalAlignment = VerticalAlignment.Bottom; break; case AdGravity.TopLeft: adControl.HorizontalAlignment = HorizontalAlignment.Left; adControl.VerticalAlignment = VerticalAlignment.Top; break; case AdGravity.TopRight: adControl.HorizontalAlignment = HorizontalAlignment.Right; adControl.VerticalAlignment = VerticalAlignment.Top; break; case AdGravity.TopCenter: adControl.HorizontalAlignment = HorizontalAlignment.Center; adControl.VerticalAlignment = VerticalAlignment.Top; break; case AdGravity.CenterScreen: adControl.HorizontalAlignment = HorizontalAlignment.Center; adControl.VerticalAlignment = VerticalAlignment.Center; break; default: Debug.LogError("AdPlugin: Unsuported Ad gravity"); break; } }
private int convertGravity(AdGravity gravity) { int gravityIndex = 0; switch (gravity) { case AdGravity.BottomLeft: gravityIndex = 0; break; case AdGravity.BottomRight: gravityIndex = 1; break; case AdGravity.BottomCenter: gravityIndex = 2; break; case AdGravity.TopLeft: gravityIndex = 3; break; case AdGravity.TopRight: gravityIndex = 4; break; case AdGravity.TopCenter: gravityIndex = 5; break; } return(gravityIndex); }
public void SetGravity(AdGravity gravity) { native.CallStatic("SetGravity", id, convertGravity(gravity)); }
public void SetGravity(AdGravity gravity) { Native.SetGravity(gravity); }
public async void SetGravity(AdGravity gravity) #endif { if (adControl == null) return; #if WINDOWS_PHONE WinRTPlugin.Dispatcher.BeginInvoke(delegate() #else await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, delegate() #endif { setGravity(gravity); }); }
public void SetGravity(AdGravity gravity) { if (adView == null) return; WinRTPlugin.Dispatcher.BeginInvoke(delegate() { setGravity(gravity); }); }
public void SetGravity(AdGravity gravity) { int gravityIndex = convertGravity(gravity); AdMob_SetAdGravity(native, gravityIndex); }
public void SetGravity(AdGravity gravity) { #if !IOS_DISABLE_GOOGLE_ADS int gravityIndex = convertGravity(gravity); AdMob_SetAdGravity(native, gravityIndex); #endif }
/// <summary> /// /// </summary> /// <param name="gravity"></param> public void SetGravity(AdGravity gravity) { // do nothing... }
public void SetGravity(AdGravity gravity) { if (desc.UseClassicGUI) { if (guiTexture == null) { return; } float screenWidth = Screen.width, screenHeight = Screen.height; float scale = (new Vector2(screenWidth, screenHeight).magnitude / new Vector2(1280, 720).magnitude) * uiScale; float adWidth = guiTexture.width * scale, adHeight = guiTexture.height * scale; switch (gravity) { case AdGravity.CenterScreen: guiRect = new Rect((screenWidth / 2) - (adWidth / 2), (screenHeight / 2) - (adHeight / 2), adWidth, adHeight); break; case AdGravity.BottomCenter: guiRect = new Rect((screenWidth / 2) - (adWidth / 2), screenHeight - adHeight, adWidth, adHeight); break; case AdGravity.BottomLeft: guiRect = new Rect(0, screenHeight - adHeight, adWidth, adHeight); break; case AdGravity.BottomRight: guiRect = new Rect(screenWidth - adWidth, screenHeight - adHeight, adWidth, adHeight); break; case AdGravity.TopCenter: guiRect = new Rect((screenWidth / 2) - (adWidth / 2), 0, adWidth, adHeight); break; case AdGravity.TopLeft: guiRect = new Rect(0, 0, adWidth, adHeight); break; case AdGravity.TopRight: guiRect = new Rect(screenWidth - adWidth, 0, adWidth, adHeight); break; default: Debug.LogError("Unsuported Gravity: " + gravity); break; } } else { if (adImage.sprite == null) { return; } float screenWidth = Screen.width, screenHeight = Screen.height; float scale = (new Vector2(screenWidth, screenHeight).magnitude / new Vector2(1280, 720).magnitude) * uiScale; var texture = adImage.sprite.texture; float adWidth = (texture.width / screenWidth) * scale, adHeight = (texture.height / screenHeight) * scale; switch (gravity) { case AdGravity.CenterScreen: adRect.anchorMin = new Vector2(-(adWidth * .5f) + .5f, -(adHeight * .5f) + .5f); adRect.anchorMax = new Vector2(-(adWidth * .5f) + .5f + adWidth, -(adHeight * .5f) + .5f + adHeight); break; case AdGravity.BottomCenter: adRect.anchorMin = new Vector2(-(adWidth * .5f) + .5f, 0); adRect.anchorMax = new Vector2(-(adWidth * .5f) + .5f + adWidth, adHeight); break; case AdGravity.BottomLeft: adRect.anchorMin = new Vector2(0, 0); adRect.anchorMax = new Vector2(adWidth, adHeight); break; case AdGravity.BottomRight: adRect.anchorMin = new Vector2(1 - adWidth, 0); adRect.anchorMax = new Vector2(1, adHeight); break; case AdGravity.TopCenter: adRect.anchorMin = new Vector2(-(adWidth * .5f) + .5f, 1 - adHeight); adRect.anchorMax = new Vector2(-(adWidth * .5f) + .5f + adWidth, 1); break; case AdGravity.TopLeft: adRect.anchorMin = new Vector2(0, 1 - adHeight); adRect.anchorMax = new Vector2(adWidth, 1); break; case AdGravity.TopRight: adRect.anchorMin = new Vector2(1 - adWidth, 1 - adHeight); adRect.anchorMax = new Vector2(1, 1); break; default: Debug.LogError("Unsuported Gravity: " + gravity); break; } adRect.offsetMin = Vector2.zero; adRect.offsetMax = Vector2.zero; } }
public void SetGravity(AdGravity gravity) { if (desc.UseClassicGUI) { float screenWidth = Screen.width, screenHeight = Screen.height; float scale = new Vector2(screenWidth, screenHeight).magnitude / new Vector2(1280, 720).magnitude; float width = 320 * scale, height = 53 * scale; if (desc.Editor_FixedWidthOverride > 0 && desc.Editor_FixedHeightOverride > 0) { width = desc.Editor_FixedWidthOverride; height = desc.Editor_FixedHeightOverride; } float adWidth = width * desc.Editor_AdScale, adHeight = height * desc.Editor_AdScale; switch (gravity) { case AdGravity.CenterScreen: guiRect = new Rect((screenWidth/2)-(adWidth/2), (screenHeight/2)-(adHeight/2), adWidth, adHeight); break; case AdGravity.BottomCenter: guiRect = new Rect((screenWidth/2)-(adWidth/2), screenHeight-adHeight, adWidth, adHeight); break; case AdGravity.BottomLeft: guiRect = new Rect(0, screenHeight-adHeight, adWidth, adHeight); break; case AdGravity.BottomRight: guiRect = new Rect(screenWidth-adWidth, screenHeight-adHeight, adWidth, adHeight); break; case AdGravity.TopCenter: guiRect = new Rect((screenWidth/2)-(adWidth/2), 0, adWidth, adHeight); break; case AdGravity.TopLeft: guiRect = new Rect(0, 0, adWidth, adHeight); break; case AdGravity.TopRight: guiRect = new Rect(screenWidth-adWidth, 0, adWidth, adHeight); break; default: Debug.LogError("Unsuported Gravity: " + gravity); break; } } else { if (adImage.sprite == null) return; float screenWidth = Screen.width, screenHeight = Screen.height; float scale = (new Vector2(screenWidth, screenHeight).magnitude / new Vector2(1280, 720).magnitude) * desc.Editor_AdScale; var texture = adImage.sprite.texture; float width = texture.width * scale, height = texture.height * scale; if (desc.Editor_FixedWidthOverride > 0 && desc.Editor_FixedHeightOverride > 0) { width = desc.Editor_FixedWidthOverride; height = desc.Editor_FixedHeightOverride; } float adWidth = (width * desc.Editor_AdScale) / screenWidth, adHeight = (height * desc.Editor_AdScale) / screenHeight; switch (gravity) { case AdGravity.CenterScreen: adRect.anchorMin = new Vector2(-(adWidth*.5f) + .5f, -(adHeight*.5f) + .5f); adRect.anchorMax = new Vector2(-(adWidth*.5f) + .5f + adWidth, -(adHeight*.5f) + .5f + adHeight); break; case AdGravity.BottomCenter: adRect.anchorMin = new Vector2(-(adWidth*.5f) + .5f, 0); adRect.anchorMax = new Vector2(-(adWidth*.5f) + .5f + adWidth, adHeight); break; case AdGravity.BottomLeft: adRect.anchorMin = new Vector2(0, 0); adRect.anchorMax = new Vector2(adWidth, adHeight); break; case AdGravity.BottomRight: adRect.anchorMin = new Vector2(1 - adWidth, 0); adRect.anchorMax = new Vector2(1, adHeight); break; case AdGravity.TopCenter: adRect.anchorMin = new Vector2(-(adWidth*.5f) + .5f, 1 - adHeight); adRect.anchorMax = new Vector2(-(adWidth*.5f) + .5f + adWidth, 1); break; case AdGravity.TopLeft: adRect.anchorMin = new Vector2(0, 1 - adHeight); adRect.anchorMax = new Vector2(adWidth, 1); break; case AdGravity.TopRight: adRect.anchorMin = new Vector2(1 - adWidth, 1 - adHeight); adRect.anchorMax = new Vector2(1, 1); break; default: Debug.LogError("Unsuported Gravity: " + gravity); break; } adRect.offsetMin = Vector2.zero; adRect.offsetMax = Vector2.zero; } }
public void SetGravity(AdGravity gravity)
public async void SetGravity(AdGravity gravity) { if (adControl == null) return; await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, delegate() { setGravity(gravity); }); }
public MM_AdPlugin(AdDesc desc, AdCreatedCallbackMethod createdCallback, MonoBehaviour service) { this.service = service; try { this.desc = desc; testing = desc.Testing; adEvent = desc.EventCallback; gravity = AdGravity.CenterScreen; #if !DISABLE_REIGN #if UNITY_EDITOR refreshRate = desc.Editor_MillennialMediaAdvertising_RefreshRate; apid = desc.Editor_MillennialMediaAdvertising_APID; userAgent = ""; gravity = desc.Editor_MillennialMediaAdvertising_AdGravity; uiScale = desc.Editor_AdScale; #elif UNITY_BLACKBERRY refreshRate = desc.BB10_MillennialMediaAdvertising_RefreshRate; apid = desc.BB10_MillennialMediaAdvertising_APID; IntPtr handle = IntPtr.Zero; if (Common.deviceinfo_get_details(ref handle) != 0) { throw new Exception("Failed: deviceinfo_get_details"); } string deviceType = Common.deviceinfo_details_get_keyboard(handle) == 0 ? "Touch" : "Kbd"; Common.deviceinfo_free_details(ref handle); string osVersion = System.Text.RegularExpressions.Regex.Match(SystemInfo.operatingSystem, @"\d*\.\d*\.\d*\.\d*").Groups[0].Value; userAgent = WWW.EscapeURL("Mozilla/5.0 (BB10; " + deviceType + ") AppleWebKit/537.10+ (KHTML, like Gecko) Version/" + osVersion + " Mobile Safari/537.10+"); gravity = desc.BB10_MillennialMediaAdvertising_AdGravity; uiScale = desc.BB10_AdScale; #elif UNITY_WP8 refreshRate = desc.WP8_MillennialMediaAdvertising_RefreshRate; apid = desc.WP8_MillennialMediaAdvertising_APID; userAgent = ""; gravity = desc.WP8_MillennialMediaAdvertising_AdGravity; uiScale = desc.WP8_AdScale; #elif UNITY_METRO refreshRate = desc.WinRT_MillennialMediaAdvertising_RefreshRate; apid = desc.WinRT_MillennialMediaAdvertising_APID; userAgent = ""; gravity = desc.WinRT_MillennialMediaAdvertising_AdGravity; uiScale = desc.WinRT_AdScale; #elif UNITY_IOS refreshRate = desc.iOS_MillennialMediaAdvertising_RefreshRate; apid = desc.iOS_MillennialMediaAdvertising_APID; userAgent = ""; gravity = desc.iOS_MillennialMediaAdvertising_AdGravity; uiScale = desc.iOS_AdScale; #elif UNITY_ANDROID refreshRate = desc.Android_MillennialMediaAdvertising_RefreshRate; apid = desc.Android_MillennialMediaAdvertising_APID; userAgent = ""; gravity = desc.Android_MillennialMediaAdvertising_AdGravity; uiScale = desc.Android_AdScale; #elif UNITY_STANDALONE_WIN refreshRate = desc.Win32_MillennialMediaAdvertising_RefreshRate; apid = desc.Win32_MillennialMediaAdvertising_APID; userAgent = ""; gravity = desc.Win32_MillennialMediaAdvertising_AdGravity; uiScale = desc.Win32_AdScale; #elif UNITY_STANDALONE_OSX refreshRate = desc.OSX_MillennialMediaAdvertising_RefreshRate; apid = desc.OSX_MillennialMediaAdvertising_APID; userAgent = ""; gravity = desc.OSX_MillennialMediaAdvertising_AdGravity; uiScale = desc.OSX_AdScale; #elif UNITY_STANDALONE_LINUX refreshRate = desc.Linux_MillennialMediaAdvertising_RefreshRate; apid = desc.Linux_MillennialMediaAdvertising_APID; userAgent = ""; gravity = desc.Linux_MillennialMediaAdvertising_AdGravity; uiScale = desc.Linux_AdScale; #endif #endif // make sure ad refresh rate doesn't go under 1 min if (refreshRate < 60) { refreshRate = 60; } // create or get device ID if (PlayerPrefs.HasKey("Reign_MMWebAds_DeviceID")) { deviceID = PlayerPrefs.GetString("Reign_MMWebAds_DeviceID"); } else { #if UNITY_EDITOR || UNITY_STANDALONE var hash = new SHA1CryptoServiceProvider().ComputeHash(Guid.NewGuid().ToByteArray()); deviceID = BitConverter.ToString(hash).ToLower(); #else deviceID = Guid.NewGuid().ToString().Replace("-", "0").ToLower() + "0000"; #endif PlayerPrefs.SetString("Reign_MMWebAds_DeviceID", deviceID); } if (desc.UseClassicGUI) { guiSytle = new GUIStyle() { stretchWidth = true, stretchHeight = true }; } else { // Create Ad Canvas adCanvas = new GameObject("MM Ad"); GameObject.DontDestroyOnLoad(adCanvas); adCanvas.AddComponent <RectTransform>(); var canvas = adCanvas.AddComponent <Canvas>(); canvas.renderMode = RenderMode.ScreenSpaceOverlay; canvas.sortingOrder = 1000; adCanvas.AddComponent <CanvasScaler>(); adCanvas.AddComponent <GraphicRaycaster>(); // Create ad var ad = new GameObject("AdButtonImage"); ad.transform.parent = adCanvas.transform; adRect = ad.AddComponent <RectTransform>(); adImage = ad.AddComponent <Image>(); adImage.sprite = Resources.Load <Sprite>("Reign/Ads/AdLoading"); adImage.preserveAspect = true; var button = ad.AddComponent <Button>(); button.onClick.AddListener(adClicked); } // set default visible state Visible = desc.Visible; SetGravity(gravity); // load ad service.StartCoroutine(init(createdCallback)); // set screen size changed callback ReignServices.ScreenSizeChangedCallback += ReignServices_ScreenSizeChangedCallback; } catch (Exception e) { Debug.LogError(e.Message); if (createdCallback != null) { createdCallback(false); } } }
/// <summary> /// Use to set the gravity of the Ad. /// </summary> /// <param name="gravity">Gravity type.</param> public void SetGravity(AdGravity gravity) { plugin.SetGravity(gravity); }
public MM_AdPlugin(AdDesc desc, AdCreatedCallbackMethod createdCallback, MonoBehaviour service) { this.service = service; try { this.desc = desc; testing = desc.Testing; adEvent = desc.EventCallback; gravity = AdGravity.CenterScreen; #if !DISABLE_REIGN #if UNITY_EDITOR refreshRate = desc.Editor_MillennialMediaAdvertising_RefreshRate; apid = desc.Editor_MillennialMediaAdvertising_APID; userAgent = ""; gravity = desc.Editor_MillennialMediaAdvertising_AdGravity; uiScale = desc.Editor_AdScale; #elif UNITY_BLACKBERRY refreshRate = desc.BB10_MillennialMediaAdvertising_RefreshRate; apid = desc.BB10_MillennialMediaAdvertising_APID; IntPtr handle = IntPtr.Zero; if (Common.deviceinfo_get_details(ref handle) != 0) throw new Exception("Failed: deviceinfo_get_details"); string deviceType = Common.deviceinfo_details_get_keyboard(handle) == 0 ? "Touch" : "Kbd"; Common.deviceinfo_free_details(ref handle); string osVersion = System.Text.RegularExpressions.Regex.Match(SystemInfo.operatingSystem, @"\d*\.\d*\.\d*\.\d*").Groups[0].Value; userAgent = WWW.EscapeURL("Mozilla/5.0 (BB10; " + deviceType + ") AppleWebKit/537.10+ (KHTML, like Gecko) Version/" + osVersion + " Mobile Safari/537.10+"); gravity = desc.BB10_MillennialMediaAdvertising_AdGravity; uiScale = desc.BB10_AdScale; #elif UNITY_WP8 refreshRate = desc.WP8_MillennialMediaAdvertising_RefreshRate; apid = desc.WP8_MillennialMediaAdvertising_APID; userAgent = ""; gravity = desc.WP8_MillennialMediaAdvertising_AdGravity; uiScale = desc.WP8_AdScale; #elif UNITY_METRO refreshRate = desc.WinRT_MillennialMediaAdvertising_RefreshRate; apid = desc.WinRT_MillennialMediaAdvertising_APID; userAgent = ""; gravity = desc.WinRT_MillennialMediaAdvertising_AdGravity; uiScale = desc.WinRT_AdScale; #elif UNITY_IOS refreshRate = desc.iOS_MillennialMediaAdvertising_RefreshRate; apid = desc.iOS_MillennialMediaAdvertising_APID; userAgent = ""; gravity = desc.iOS_MillennialMediaAdvertising_AdGravity; uiScale = desc.iOS_AdScale; #elif UNITY_ANDROID refreshRate = desc.Android_MillennialMediaAdvertising_RefreshRate; apid = desc.Android_MillennialMediaAdvertising_APID; userAgent = ""; gravity = desc.Android_MillennialMediaAdvertising_AdGravity; uiScale = desc.Android_AdScale; #elif UNITY_STANDALONE_WIN refreshRate = desc.Win32_MillennialMediaAdvertising_RefreshRate; apid = desc.Win32_MillennialMediaAdvertising_APID; userAgent = ""; gravity = desc.Win32_MillennialMediaAdvertising_AdGravity; uiScale = desc.Win32_AdScale; #elif UNITY_STANDALONE_OSX refreshRate = desc.OSX_MillennialMediaAdvertising_RefreshRate; apid = desc.OSX_MillennialMediaAdvertising_APID; userAgent = ""; gravity = desc.OSX_MillennialMediaAdvertising_AdGravity; uiScale = desc.OSX_AdScale; #elif UNITY_STANDALONE_LINUX refreshRate = desc.Linux_MillennialMediaAdvertising_RefreshRate; apid = desc.Linux_MillennialMediaAdvertising_APID; userAgent = ""; gravity = desc.Linux_MillennialMediaAdvertising_AdGravity; uiScale = desc.Linux_AdScale; #endif #endif // make sure ad refresh rate doesn't go under 1 min if (refreshRate < 60) refreshRate = 60; // create or get device ID if (PlayerPrefs.HasKey("Reign_MMWebAds_DeviceID")) { deviceID = PlayerPrefs.GetString("Reign_MMWebAds_DeviceID"); } else { #if UNITY_EDITOR || UNITY_STANDALONE var hash = new SHA1CryptoServiceProvider().ComputeHash(Guid.NewGuid().ToByteArray()); deviceID = BitConverter.ToString(hash).ToLower(); #else deviceID = Guid.NewGuid().ToString().Replace("-", "0").ToLower() + "0000"; #endif PlayerPrefs.SetString("Reign_MMWebAds_DeviceID", deviceID); } if (desc.UseClassicGUI) { guiSytle = new GUIStyle() { stretchWidth = true, stretchHeight = true }; } else { // Create Ad Canvas adCanvas = new GameObject("MM Ad"); GameObject.DontDestroyOnLoad(adCanvas); adCanvas.AddComponent<RectTransform>(); var canvas = adCanvas.AddComponent<Canvas>(); canvas.renderMode = RenderMode.ScreenSpaceOverlay; canvas.sortingOrder = 1000; adCanvas.AddComponent<CanvasScaler>(); adCanvas.AddComponent<GraphicRaycaster>(); // Create ad var ad = new GameObject("AdButtonImage"); ad.transform.parent = adCanvas.transform; adRect = ad.AddComponent<RectTransform>(); adImage = ad.AddComponent<Image>(); adImage.sprite = Resources.Load<Sprite>("Reign/Ads/AdLoading"); adImage.preserveAspect = true; var button = ad.AddComponent<Button>(); button.onClick.AddListener(adClicked); } // set default visible state Visible = desc.Visible; SetGravity(gravity); // load ad service.StartCoroutine(init(createdCallback)); // set screen size changed callback ReignServices.ScreenSizeChangedCallback += ReignServices_ScreenSizeChangedCallback; } catch (Exception e) { Debug.LogError(e.Message); if (createdCallback != null) createdCallback(false); } }