void Update() { ArrayList list = new ArrayList (); DeviceOrientation orientation = Input.deviceOrientation; if (_lastOrientation != orientation) { switch (orientation) { case DeviceOrientation.LandscapeLeft: case DeviceOrientation.LandscapeRight: case DeviceOrientation.Portrait: case DeviceOrientation.PortraitUpsideDown: list.Add (new FageScreenEvent (_lastOrientation, Input.deviceOrientation)); _lastOrientation = orientation; break; } } if ((_lastWidth != Screen.width) || (_lastHeight != Screen.height)) { list.Add (new FageScreenEvent (_lastWidth, _lastHeight, Screen.width, Screen.height)); _lastWidth = Screen.width; _lastHeight = Screen.height; } if (_lastDpi != Screen.dpi) { list.Add (new FageScreenEvent (_lastDpi, Screen.dpi)); _lastDpi = Screen.dpi; } foreach (FageScreenEvent fsevent in list) { DispatchEvent(fsevent); } }
public TestBase(DeviceOrientation orientation) { Director.Instance.DeviceOrientation = orientation; SizeF s = Director.Instance.WinSize; Label label = new Label(ToString(), "Arial", 32); AddChild(label, 100); label.SetPosition(s.Width / 2f, s.Height - 50); MenuItemImage item1 = new MenuItemImage("b1.png", "b2.png"); item1.Click += OnBack; MenuItemImage item2 = new MenuItemImage("r1.png", "r2.png"); item2.Click += OnRestart; MenuItemImage item3 = new MenuItemImage("f1.png", "f2.png"); item3.Click += OnForward; Menu menu = new Menu(item1, item2, item3); menu.SetPosition(PointF.Empty); float windowWidth = Director.Instance.WinSize.Width; item1.SetPosition(windowWidth / 2 - 100, 30); item2.SetPosition(windowWidth / 2, 30); item3.SetPosition(windowWidth / 2 + 100, 30); AddChild(menu, 5000); }
void Update() { if (Input.deviceOrientation == DeviceOrientation.FaceDown && m_LastOrientation != DeviceOrientation.FaceDown) { if ( null != OnDeviceFaceDown ) OnDeviceFaceDown( this, new System.EventArgs() ); } if (Input.deviceOrientation == DeviceOrientation.FaceUp && m_LastOrientation != DeviceOrientation.FaceUp) { if ( null != OnDeviceFaceUp ) OnDeviceFaceUp( this, new System.EventArgs() ); } if (Input.deviceOrientation == DeviceOrientation.LandscapeLeft && m_LastOrientation != DeviceOrientation.LandscapeLeft) { if ( null != OnDeviceLandscapeLeft ) OnDeviceLandscapeLeft( this, new System.EventArgs() ); } if (Input.deviceOrientation == DeviceOrientation.LandscapeRight && m_LastOrientation != DeviceOrientation.LandscapeRight) { if ( null != OnDeviceLandscapeRight ) OnDeviceLandscapeRight( this, new System.EventArgs() ); } if (Input.deviceOrientation == DeviceOrientation.Portrait && m_LastOrientation != DeviceOrientation.Portrait) { if ( null != OnDevicePortrait ) OnDevicePortrait( this, new System.EventArgs() ); } if (Input.deviceOrientation == DeviceOrientation.PortraitUpsideDown && m_LastOrientation != DeviceOrientation.PortraitUpsideDown) { if ( null != OnDevicePortraitUpsideDown ) OnDevicePortraitUpsideDown( this, new System.EventArgs() ); } m_LastOrientation = Input.deviceOrientation; }
// Update is called once per frame void Update() { last = current; if ( !lockOrientation ){ current = Input.deviceOrientation; } if (SystemInfo.deviceType == DeviceType.Desktop ) { if ( lockOrientation ){ if ( Input.GetKeyDown(KeyCode.Alpha1) ){ current = DeviceOrientation.LandscapeLeft; } else if ( Input.GetKeyDown(KeyCode.Alpha2) ){ current = DeviceOrientation.Portrait; } else if ( Input.GetKeyDown(KeyCode.Alpha3) ){ current = DeviceOrientation.LandscapeRight; } } if ( Input.GetKeyDown(KeyCode.Tab) ){ lockOrientation = !lockOrientation; } } if (last != current) { if (OrientationChange != null) { OrientationChange(); } } }
IEnumerator CheckForChange() { resolution = new Vector2(Screen.width, Screen.height); orientation = Input.deviceOrientation; while (isAlive) { // Check for a Resolution Change if (resolution.x != Screen.width || resolution.y != Screen.height) { var previousResolution = resolution; resolution = new Vector2(Screen.width, Screen.height); Messenger.Fire("DeviceOrientationNotifier.ResolutionChange", new object[] { resolution, previousResolution }); } // Check for an Orientation Change switch (Input.deviceOrientation) { case DeviceOrientation.Unknown:// Ignore case DeviceOrientation.FaceUp:// Ignore case DeviceOrientation.FaceDown:// Ignore break; default: if (orientation != Input.deviceOrientation) { var previousOrientation = orientation; orientation = Input.deviceOrientation; Messenger.Fire("DeviceOrientationNotifier.OrientationChange", new object[] { orientation, previousOrientation }); } break; } yield return new WaitForSeconds(CheckDelay); } }
public override void OnEnter() { _currentOrientation = Input.deviceOrientation; if (!ignoreInitialOrientation) { FireOrientationEvent(); } }
void DoWatchDeviceOrientation() { if (Input.deviceOrientation != _currentOrientation) { _currentOrientation = Input.deviceOrientation; FireOrientationEvent(); } }
void Awake() { _instance = this; _lastOrientation = Input.deviceOrientation; _lastWidth = Screen.width; _lastHeight = Screen.height; _lastDpi = Screen.dpi; }
// The hardware reading of device orientation is screwy, so this replaces that void CheckCurrentOrientation() { #if UNITY_EDITOR float camRot = Camera.main.transform.rotation.eulerAngles.z; if (camRot >= 315f || camRot < 45) currentOrientation = DeviceOrientation.Portrait; else if (camRot >= 225f) currentOrientation = DeviceOrientation.LandscapeLeft; else if (camRot >= 135f) currentOrientation = DeviceOrientation.PortraitUpsideDown; else currentOrientation = DeviceOrientation.LandscapeRight; #else if (deviceGravity.x >= tiltOrientationChangeThreshold) { if (Mathf.Abs(deviceGravity.x) > Mathf.Abs(deviceGravity.y)) currentOrientation = DeviceOrientation.LandscapeRight; else if (deviceGravity.y < 0) currentOrientation = DeviceOrientation.Portrait; else currentOrientation = DeviceOrientation.PortraitUpsideDown; } else if (deviceGravity.x <= -tiltOrientationChangeThreshold) { if (Mathf.Abs(deviceGravity.x) > Mathf.Abs(deviceGravity.y)) currentOrientation = DeviceOrientation.LandscapeLeft; else if (deviceGravity.y < 0) currentOrientation = DeviceOrientation.Portrait; else currentOrientation = DeviceOrientation.PortraitUpsideDown; } else { if (deviceGravity.y >= tiltOrientationChangeThreshold) currentOrientation = DeviceOrientation.PortraitUpsideDown; else if (deviceGravity.y <= -tiltOrientationChangeThreshold) currentOrientation = DeviceOrientation.Portrait; else if (deviceGravity.z <= 0) currentOrientation = DeviceOrientation.FaceUp; else currentOrientation = DeviceOrientation.FaceDown; } #endif }
void LateUpdate() { DeviceOrientation newOrientation = Input.deviceOrientation; if (newOrientation != DeviceOrientation.FaceDown && newOrientation != DeviceOrientation.FaceUp && newOrientation != DeviceOrientation.Unknown) { if (newOrientation != currentOrientation) { if (OrientationChangedToEvent != null) { OrientationChangedToEvent(newOrientation); } if (OrientationChangedEvent != null) { OrientationChangedEvent(); } currentOrientation = newOrientation; } } }
private void handleOrientationChangedToEvent(DeviceOrientation newOrientation) { from = transform.localRotation.eulerAngles; if (newOrientation == DeviceOrientation.LandscapeRight) { to = new Vector3(0f, 0f, 90f); } if (newOrientation == DeviceOrientation.LandscapeLeft) { to = new Vector3(0f, 0f, -90f); } if (newOrientation == DeviceOrientation.Portrait) { to = new Vector3(0f, 0f, 0f); } if (newOrientation == DeviceOrientation.PortraitUpsideDown) { to = new Vector3(0f, 0f, -180f); } Play(true); }
// Update is called once per frame void Update() { if (dirty && orientation != Input.deviceOrientation) { bool isDirty = false; switch (Input.deviceOrientation) { case DeviceOrientation.Portrait: case DeviceOrientation.PortraitUpsideDown: if (Screen.height > Screen.width) { cScaler.matchWidthOrHeight = 1; isDirty = true; } break; case DeviceOrientation.LandscapeLeft: case DeviceOrientation.LandscapeRight: if (Screen.width > Screen.height) { cScaler.matchWidthOrHeight = 0; isDirty = true; } break; default: break; } if (isDirty) { orientation = Input.deviceOrientation; onChangeOrientation.Invoke(orientation); dirty = false; } } }
internal static void ResetDeviceOrientation(DeviceOrientation supportedOrientation) { switch (supportedOrientation) { case DeviceOrientation.AllLandscapes: case DeviceOrientation.LandscapeLeft: SetDeviceOrientation(UIInterfaceOrientation.LandscapeLeft); break; case DeviceOrientation.LandscapeRight: SetDeviceOrientation(UIInterfaceOrientation.LandscapeRight); break; case DeviceOrientation.AllPortraits: case DeviceOrientation.Portrait: SetDeviceOrientation(UIInterfaceOrientation.Portrait); break; case DeviceOrientation.PortraitUpsideDown: SetDeviceOrientation(UIInterfaceOrientation.PortraitUpsideDown); break; } UIViewController.AttemptRotationToDeviceOrientation(); }
private void Awake() { this.currentDeviceOrientation = Input.deviceOrientation; }
/// <summary> /// Size changed, determine if we need to update the layout. /// </summary> /// <param name="width">The new width.</param> /// <param name="height">The new height.</param> protected override void OnSizeAllocated(double width, double height) { base.OnSizeAllocated(width, height); if (width > height && orientation != DeviceOrientation.Landscape) { orientation = DeviceOrientation.Landscape; OuterGrid.RowDefinitions.Clear(); OuterGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); OuterGrid.ColumnDefinitions.Clear(); OuterGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0.5, GridUnitType.Star) }); OuterGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0.5, GridUnitType.Star) }); OuterGrid.Children.Remove(Image); OuterGrid.Children.Add(Image, 0, 0); OuterGrid.Children.Remove(InnerGrid); OuterGrid.Children.Add(InnerGrid, 1, 0); InnerGrid.RowDefinitions.Clear(); InnerGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(0.8, GridUnitType.Star) }); InnerGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(0.2, GridUnitType.Star) }); Image.Margin = new Thickness(5, 5, 0, 5); AbsoluteLayout.Children.Remove(NextSideButton); AbsoluteLayout.Children.Add(NextSideButton, new Rectangle(1, 0.5, 0.15, 0.25), AbsoluteLayoutFlags.All); } else if (width < height && orientation != DeviceOrientation.Portrait) { orientation = DeviceOrientation.Portrait; OuterGrid.ColumnDefinitions.Clear(); OuterGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); OuterGrid.RowDefinitions.Clear(); //The image got a ratio of 9:7 var imageGridHeight = width / height / 9 * 7; OuterGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(imageGridHeight, GridUnitType.Star) }); OuterGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1 - imageGridHeight, GridUnitType.Star) }); OuterGrid.Children.Remove(Image); OuterGrid.Children.Add(Image, 0, 0); OuterGrid.Children.Remove(InnerGrid); OuterGrid.Children.Add(InnerGrid, 0, 1); InnerGrid.RowDefinitions.Clear(); InnerGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(0.7, GridUnitType.Star) }); InnerGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(0.3, GridUnitType.Star) }); Image.Margin = new Thickness(5, 5, 5, 0); AbsoluteLayout.Children.Remove(NextSideButton); AbsoluteLayout.Children.Add(NextSideButton, new Rectangle(1, 0.5, 0.2, 0.1), AbsoluteLayoutFlags.All); } }
public DeviceOrientationChangedMessage(DeviceOrientation oldDeviceOrientation, DeviceOrientation newDeviceOrientation) { OldDeviceOrientation = oldDeviceOrientation; NewDeviceOrientation = newDeviceOrientation; }
void OnGetDeviceOrientationButtonClicked(object sender, EventArgs e) { DeviceOrientation orientation = DependencyService.Get <IDeviceOrientationService>().GetOrientation(); orientationLabel.Text = orientation.ToString(); }
public AdventurerDetailsView() { InitializeComponent(); deviceOrientation = DeviceOrientation.Undefined; }
bool IsPortrait(DeviceOrientation orient) { return orient == DeviceOrientation.Portrait || orient == DeviceOrientation.PortraitUpsideDown; }
// Update is called once per frame void Update() { lastOrientaion = Input.deviceOrientation; }
public static bool IsLandscape(this DeviceOrientation orientation) { return(orientation == DeviceOrientation.Landscape || orientation == DeviceOrientation.LandscapeLeft || orientation == DeviceOrientation.LandscapeRight); }
protected virtual void OnDeviceOrientationChanged (DeviceOrientation newOrientation) {}
// Use this for initialization void Start() { last = DeviceOrientation.Unknown; current = Input.deviceOrientation; // Debug.Log (SystemInfo.deviceType); }
public static void setInterfaceOrientation( DeviceOrientation orientation ) { }
public static void setInterfaceOrientation( DeviceOrientation orientation ) { if( Application.platform == RuntimePlatform.IPhonePlayer ) { // only allow valid orientations if( orientation == DeviceOrientation.Unknown || orientation == DeviceOrientation.FaceUp || orientation == DeviceOrientation.FaceDown ) { Debug.LogError( "Invalid orientation specified: " + orientation ); } else { _kiipSetInterfaceOrientation( (int)orientation ); } } }
bool IsLandscape(DeviceOrientation orient) { return orient == DeviceOrientation.LandscapeLeft || orient == DeviceOrientation.LandscapeRight; }
/// <summary> /// Gets the sauce labs web driver. /// </summary> /// <param name="browserName">The full browser name.</param> /// <param name="os">The operating system.</param> /// <param name="apiName">The api name.</param> /// <param name="device">The device name.</param> /// <param name="version">The version name.</param> /// <param name="testSettings">The test settings.</param> /// <param name="deviceOrientation">The device orientation.</param> /// <param name="testOutputHelper">The test output helper.</param> /// <returns></returns> /// <exception cref="TestConfigurationException">Selenium settings not set.</exception> public static ITestWebDriver InitializeSauceLabsDriver(string browserName, string os, string apiName, string device, string version, TestSettings testSettings, DeviceOrientation deviceOrientation, ITestOutputHelper testOutputHelper) { ScreenShotCounter = 0; TestOutputHelper = testOutputHelper; testSettings.BrowserName = browserName; if (testSettings.SeleniumHubSettings == null) { throw new TestConfigurationException("SauceLabs settings not set."); } if (testSettings.SeleniumHubSettings.HubUsername == null) { throw new TestConfigurationException("SauceLabs username settings not set."); } if (testSettings.SeleniumHubSettings.HubPassword == null) { throw new TestConfigurationException("SauceLabs access token settings not set."); } var capabilities = SauceLabs.GetDesiredCapability(testSettings.SeleniumHubSettings.HubUsername, testSettings.SeleniumHubSettings.HubPassword, browserName, os, apiName, device, version, deviceOrientation, testSettings); testSettings = ValidateSavePaths(testSettings); var driver = new TestRemoteWebDriver(new Uri(testSettings.SeleniumHubSettings.HubUrl), capabilities, testSettings.TimeoutTimeSpan); var extendedWebDriver = new TestWebDriver(driver, testSettings, TestOutputHelper); TestWebDriver = extendedWebDriver; return extendedWebDriver; }
/// <summary> /// To update list settings based on the orientation and store the current oriantetion. /// </summary> void OrientationUpdate () { DevOri = Input.deviceOrientation; //update device orientation to the current one if (Screen.width <= Screen.height ) { //handle landscape or square scenario customStyle.fontSize = Mathf.FloorToInt(Screen.width / 18f); //set the font size based on screen size listPositioner = 3; //set wthe adjust helper of the list listWidth = Screen.width * 2f; //set list width listHeight = Mathf.FloorToInt (Screen.height / 15f); //set list height listYdiff = Mathf.FloorToInt (Screen.height / 15f); //set list item distance } else { //handle portrait scenario customStyle.fontSize = Mathf.FloorToInt(Screen.height / 18f); //set the font size based on screen size listPositioner = 4; //set wthe adjust helper of the list listWidth = Screen.width * 2f; //set list width listHeight = Mathf.FloorToInt (Screen.width / 15f);//set list height listYdiff = Mathf.FloorToInt (Screen.width / 15f); //set list item distance } }
//----- Development Debug -------- // void OnGUI() // { // GUILayout.BeginVertical(); // var lab = new GUIStyle(); // lab.fontStyle = FontStyle.Bold; // lab.normal.textColor = Color.red; // GUILayout.Label("Released: " + Released, lab); // GUILayout.Label("AnalogicStartPosition: " + AnalogicStartPosition, lab); // GUILayout.Label("Touchs: "+Input.touchCount, lab); // for (int i = 0; i < Input.touchCount; i++) // { // GUILayout.Label("Touch: "+Input.GetTouch(i), lab); // GUILayout.Label(" Id: "+i); // GUILayout.Label(" fingerId: "+Input.GetTouch(i).fingerId); // GUILayout.Label(" hash: "+Input.GetTouch(i).GetHashCode(), lab); // GUILayout.Label(" phase: "+Input.GetTouch(i).phase, lab); // GUILayout.Label(" position: "+Input.GetTouch(i).position, lab); // GUILayout.Label(" hash: "+Input.GetTouch(i).GetHashCode(), lab); // } // GUILayout.EndVertical(); // } public override void Start() { base.Start(); // Input.RegisterAxisMobile(VerticalAxis); // Input.RegisterAxisMobile(HorizontalAxis); rectTransform = GetComponent <RectTransform>(); imageUI = GetComponent <Image>(); if (rectTransform == null) { Debug.Log("Specify the object of the knob"); } Canvas canvas = GetComponentInParent <Canvas>(); if (canvas == null) { Debug.LogError("canvas not found, put this object as children of an canvas."); } RectTransform CanvasRect = canvas.GetComponent <RectTransform>(); AnchoredAreaBounds = new Bounds(new Vector2(NormalizedAnchoredAreaBounds.center.x * CanvasRect.sizeDelta.x, NormalizedAnchoredAreaBounds.center.y * CanvasRect.sizeDelta.y) , new Vector2(NormalizedAnchoredAreaBounds.size.x * CanvasRect.sizeDelta.x, NormalizedAnchoredAreaBounds.size.y * CanvasRect.sizeDelta.y)); if (AnalogicStartAnchoredPosition == Vector2.zero) { AnalogicStartAnchoredPosition = rectTransform.anchoredPosition; } else { rectTransform.anchoredPosition = AnalogicStartAnchoredPosition; } AnalogicStartPosition = transform.position; ScreenPixels = new Vector2(Screen.width, Screen.height); CanvasSize = CanvasRect.sizeDelta; CanvasScale = canvas.transform.lossyScale.x; ScreenToAnchorPositionConversionConstant = new Vector2(CanvasSize.x / ScreenPixels.x, CanvasSize.y / ScreenPixels.y); ScreenUnitsToWorldUnitsConversionConstant = ScreenToAnchorPositionConversionConstant.y * CanvasScale; _MaxDistance = TurnLimit / ScreenToAnchorPositionConversionConstant.y; canvasInitialPoint = canvas.transform.position + (new Vector3(-CanvasSize.x * canvas.transform.lossyScale.x * 0.5f, -CanvasSize.y * canvas.transform.lossyScale.y * 0.5f)); Vector3 knobUnAnchoredPositionOnCanvas = (transform.position - canvasInitialPoint) / canvas.transform.lossyScale.y; MinScreenAreaBounds = (knobUnAnchoredPositionOnCanvas + AnchoredAreaBounds.min) / ScreenToAnchorPositionConversionConstant.y; MaxScreenAreaBounds = (knobUnAnchoredPositionOnCanvas + AnchoredAreaBounds.max) / ScreenToAnchorPositionConversionConstant.y; ScreenCenterAreaBounds = (knobUnAnchoredPositionOnCanvas + AnchoredAreaBounds.center) / ScreenToAnchorPositionConversionConstant.y; ScreenRadiusAreaBounds = AnchoredAreaBounds.extents.x / ScreenToAnchorPositionConversionConstant.y; if (clampMode == ClampMode.Box) { IsInsideArea = CheckBoxArea; } else { IsInsideArea = CheckCircleArea; } Released = true; InsideAreaFingerId = -1; if (autoHide) { imageUI.CrossFadeAlpha(0f, StartFadeOutDuration, true); if (KnobBackground != null) { KnobBackground.CrossFadeAlpha(0f, StartFadeOutDuration, true); } } _devOrientation = UnityEngine.Input.deviceOrientation; }
void OnScreenOrientationChange(DeviceOrientation preOri, DeviceOrientation newOri) { this.SetDirty(); }
// A Coroutine for retrieving the current location // protected IEnumerator GetPosition() { #if UNITY_EDITOR // If in editor mode, set a fixed initial location and forget about the location service // FilteredLatitude = OriginalLatitude = 48.158464f; FilteredLongitude = OriginalLongitude = 11.578708f; Debug.Log("UNITY_EDITOR fixed location, lat " + FilteredLatitude + ", lon " + FilteredLongitude); while (FilteredLatitude <= 90) { yield return(new WaitForSeconds(3600f)); } // End of editor mode #endif int nFails = 0; bool doInitialize = true; while (IsEmpty(ErrorMessage)) { while (InfoPanelIsActive()) { yield return(new WaitForSeconds(.01f)); } if (doInitialize) { doInitialize = false; Input.compass.enabled = true; int maxWait = 4500; #if PLATFORM_ANDROID bool first = true; while (!Permission.HasUserAuthorizedPermission(Permission.FineLocation) && maxWait > 0) { if (first) { Permission.RequestUserPermission(Permission.FineLocation); first = false; } yield return(new WaitForSeconds(.01f)); maxWait--; } #endif if (_locationService == null) { _locationService = new LocationService(); if (!_locationService.isEnabledByUser) { ErrorMessage = $"Please enable the location service for the {AppName} app."; yield break; } } Input.location.Start(.1f, .1f); yield return(new WaitForSeconds(.2f)); maxWait = 3000; while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0) { yield return(new WaitForSeconds(.01f)); maxWait--; } if (maxWait < 1) { ErrorMessage = "Location service didn't initialize in 30 seconds."; yield break; } if (Input.location.status == LocationServiceStatus.Failed) { if (++nFails > 10) { ErrorMessage = $"Please enable the location service for the {AppName} app."; yield break; } Input.location.Stop(); doInitialize = true; continue; } FilteredLatitude = OriginalLatitude = Input.location.lastData.latitude; FilteredLongitude = OriginalLongitude = Input.location.lastData.longitude; InitialDeviceOrientation = Input.deviceOrientation; } // For the first .2 seconds we remember the initial camera heading if (CameraIsInitializing && StartTicks > 0 && DateTime.Now.Ticks > StartTicks + 2000000) { CameraIsInitializing = false; } CurrentHeading = Input.compass.trueHeading; if (LocationLatitude != Input.location.lastData.latitude || LocationLongitude != Input.location.lastData.longitude || LocationTimestamp != Input.location.lastData.timestamp || LocationHorizontalAccuracy != Input.location.lastData.horizontalAccuracy ) { LocationLatitude = Input.location.lastData.latitude; LocationLongitude = Input.location.lastData.longitude; LocationTimestamp = Input.location.lastData.timestamp; LocationHorizontalAccuracy = Input.location.lastData.horizontalAccuracy; KalmanFilter(LocationLatitude, LocationLongitude, LocationHorizontalAccuracy, (long)(1000L * LocationTimestamp)); } var arObjectState = ArObjectState; if (arObjectState != null) { PlaceArObjects(arObjectState); } yield return(new WaitForSeconds(.01f)); } yield break; }
public ExhibitRouteDownloadPage() { InitializeComponent(); DesignMode.Initialize(this); orientation = DeviceOrientation.Undefined; }
/// <summary> Checks if the screen size changed and repaints if it did. /// Called by <see cref="UI.Update"/>.</summary> public static void Update() { if (UI.GUICamera == null) { // PowerUI is offline. return; } bool changedX = false; bool changedY = false; if (UnityEngine.Screen.width != ScreenX) { ScreenX = UnityEngine.Screen.width; ScreenXFloat = (float)ScreenX; changedX = true; } if (UnityEngine.Screen.height != ScreenY) { ScreenY = UnityEngine.Screen.height; ScreenYFloat = (float)ScreenY; changedY = true; } HtmlDocument document = UI.document; // Device orientation changed? bool landscape = IsLandscape(); Css.MediaType media; if (PreviousOrientation == DeviceOrientation.Unknown) { // First time. Straight set it: PreviousOrientation = landscape?DeviceOrientation.LandscapeLeft : DeviceOrientation.Portrait; } else { // Changed? if (landscape && PreviousOrientation != DeviceOrientation.LandscapeLeft) { // Orientation changed! Update previous: PreviousOrientation = landscape?DeviceOrientation.LandscapeLeft : DeviceOrientation.Portrait; // Inform main UI media rules: media = document.MediaIfExists; if (media != null) { // Nudge it! media.Landscape = landscape; } // Fire the rotation event now (on the window): // We're using absolute here because 'deviceorientation' is the actual angle of the device. DeviceOrientationEvent e = new DeviceOrientationEvent("deviceorientationabsolute"); e.absolute = true; e.SetTrusted(); document.window.dispatchEvent(e); } } if (!changedX && !changedY) { return; } // Nudge the matrices: UI.GUICamera.ResetWorldToCameraMatrix(); UI.GUICamera.ResetProjectionMatrix(); UI.GUICamera.ResetAspect(); // Firstly, find the bottom left and top right corners at UI.CameraDistance z units away (zero z-index): Vector3 bottomLeft = UI.GUICamera.ScreenToWorldPoint(new Vector3(0f, 0f, UI.CameraDistance)); Vector3 topRight = UI.GUICamera.ScreenToWorldPoint(new Vector3(ScreenX, ScreenY, UI.CameraDistance)); // With those, we can now find the size of the screen in world units: WorldSize.x = topRight.x - bottomLeft.x; WorldSize.y = topRight.y - bottomLeft.y; // Finally, calculate WorldPerPixel at zero depth: // Mapping PX to world units: WorldPerPixel.x = WorldSize.x / (float)ScreenX; WorldPerPixel.y = WorldSize.y / (float)ScreenY; // Set where the origin is. All rendering occurs relative to this point. // It's offset by 0.2 pixels to target a little closer to the middle of each pixel. This helps Pixel filtering look nice and clear. WorldScreenOrigin.y = bottomLeft.y + (0.4f * WorldPerPixel.y); WorldScreenOrigin.x = bottomLeft.x - (0.4f * WorldPerPixel.x); // Update main document's viewport: document.Viewport.Update(ScreenXFloat, ScreenYFloat); // Fire the resize event (doesn't bubble): Dom.Event resize = new Dom.Event("resize"); resize.SetTrusted(false); document.window.dispatchEvent(resize); // Inform main UI media rules: media = document.MediaIfExists; // Resize: if (changedX) { int w = (int)ScreenXFloat; document.RequestLayout(); if (media != null) { // Nudge it! media.Width = w; } } if (changedY) { int h = (int)ScreenYFloat; document.RequestLayout(); if (media != null) { // Nudge it! media.Height = h; } } }
void OnChangeOrientation(DeviceOrientation orientation) { ApplySafeArea(); }
// Update is called once per frame. public void Update() { if(Application.platform.Equals(RuntimePlatform.Android)){ if(deviceOrientation != Input.deviceOrientation && (Input.deviceOrientation == DeviceOrientation.LandscapeLeft || Input.deviceOrientation == DeviceOrientation.LandscapeRight || Input.deviceOrientation == DeviceOrientation.Portrait || Input.deviceOrientation == DeviceOrientation.PortraitUpsideDown)){ deviceOrientation = Input.deviceOrientation; DeviceOrientationSwitched = true; } else if(DeviceOrientationSwitched){ DeviceOrientationSwitched = false; } } // Screen size can dynamically change at any time via the GUI. if(screenSize != new Vector2(Screen.width, Screen.height)){ screenSize = new Vector2(Screen.width, Screen.height); } // Not sure if needed but not taking a chance. if(screenResolution != new Vector2(Screen.currentResolution.width, Screen.currentResolution.height)){ screenResolution = new Vector2(Screen.currentResolution.width, Screen.currentResolution.height); } if(screenOrientation != Screen.orientation){ screenOrientation = Screen.orientation; } }
public override void Reset() { orientation = DeviceOrientation.Portrait; sendEvent = null; everyFrame = false; }
public void Initialize() { if (occupiedPixels == null) { int screenWidth = ScreenDimentions.Width; int screenHeight = ScreenDimentions.Height; int width = screenWidth; int height = screenHeight; bool isLandscapeOrientation; if (rotationType == GUILayouterRotationType.Both) { #if UNITY_EDITOR isLandscapeOrientation = (width > height); #else if ((Screen.autorotateToLandscapeLeft) || (Screen.autorotateToLandscapeRight) || (Screen.autorotateToPortrait) || (Screen.autorotateToPortraitUpsideDown)) { DeviceOrientation deviceOrientation = Input.deviceOrientation; if ((deviceOrientation == DeviceOrientation.LandscapeLeft && Screen.autorotateToLandscapeLeft) || (deviceOrientation == DeviceOrientation.LandscapeRight && Screen.autorotateToLandscapeRight)) { isLandscapeOrientation = true; } else if ((deviceOrientation == DeviceOrientation.Portrait && Screen.autorotateToPortrait) || (deviceOrientation == DeviceOrientation.PortraitUpsideDown && Screen.autorotateToPortraitUpsideDown)) { isLandscapeOrientation = false; } else { isLandscapeOrientation = (width > height); } } else { ScreenOrientation screenOrientation = Screen.orientation; if (screenOrientation == ScreenOrientation.LandscapeLeft || screenOrientation == ScreenOrientation.LandscapeRight || screenOrientation == ScreenOrientation.Landscape) { isLandscapeOrientation = true; } else if (screenOrientation == ScreenOrientation.Portrait || screenOrientation == ScreenOrientation.PortraitUpsideDown) { isLandscapeOrientation = false; } else { isLandscapeOrientation = (width > height); } } #endif } else { isLandscapeOrientation = (rotationType == GUILayouterRotationType.Landscape); } width = isLandscapeOrientation ? Mathf.Max(screenWidth, screenHeight) : Mathf.Min(screenWidth, screenHeight); height = isLandscapeOrientation ? Mathf.Min(screenWidth, screenHeight) : Mathf.Max(screenWidth, screenHeight); OccupiedPixels = new Rect?(new Rect(0, 0, width, height)); } }
/// <summary> /// Gets the desired browser capability. /// </summary> /// <param name="username">The username.</param> /// <param name="accessKey">The access key.</param> /// <param name="browserName">Name of the browser.</param> /// <param name="os">The os.</param> /// <param name="apiName">Name of the API.</param> /// <param name="device">The device.</param> /// <param name="version">The version.</param> /// <param name="orientation">The device orientation.</param> /// <param name="testSettings">The test settings.</param> /// <returns></returns> /// <exception cref="TestConfigurationException">Unable to set the desired capabilities</exception> public static DesiredCapabilities GetDesiredCapability(string username, string accessKey, string browserName, string os, string apiName, string device, string version, DeviceOrientation orientation, TestSettings testSettings) { DesiredCapabilities caps = null; switch (apiName) { case "iphone": case "ipad": caps = DesiredCapabilities.IPad(); caps.SetCapability("browserName", apiName); caps.SetCapability("platform", "OS X " + os.Replace("Mac ","")); caps.SetCapability("version", version); caps.SetCapability("deviceName", device); caps.SetCapability("deviceOrientation", orientation == DeviceOrientation.Portrait ? "portrait" : "landscape"); caps.SetCapability("username", username); caps.SetCapability("accessKey", accessKey); caps.SetCapability("name", browserName + " - " + DateTime.Now.ToString("F")); caps.SetCapability("javascriptEnabled", true); caps.SetCapability("acceptSslCerts", true); caps.SetCapability("takesScreenshot", testSettings.LogScreenShots); return caps; case "chrome": case "firefox": case "internet explorer": case "microsoftedge": case "opera": case "safari": switch (apiName) { case "chrome": caps = DesiredCapabilities.Chrome(); break; case "firefox": caps = DesiredCapabilities.Firefox(); break; case "internet explorer": caps = DesiredCapabilities.InternetExplorer(); break; case "microsoftedge": caps = DesiredCapabilities.Edge(); break; case "opera": caps = DesiredCapabilities.Opera(); break; case "safari": caps = DesiredCapabilities.Safari(); break; default: caps = DesiredCapabilities.HtmlUnit(); break; } caps.SetCapability("browserName", device); caps.SetCapability("platform", os); caps.SetCapability("version", version); caps.SetCapability("username", username); caps.SetCapability("accessKey", accessKey); caps.SetCapability("name", browserName + " - " + DateTime.Now.ToString("F")); caps.SetCapability("javascriptEnabled", true); caps.SetCapability("acceptSslCerts", true); caps.SetCapability("takesScreenshot", testSettings.LogScreenShots); return caps; case "android": caps = DesiredCapabilities.Android(); if (device == "Android") { caps.SetCapability("browserName", device); caps.SetCapability("platform", os); caps.SetCapability("version", version); caps.SetCapability("deviceName", "Android Emulator"); } else { caps.SetCapability("browserName", "Android"); caps.SetCapability("deviceName", device); } caps.SetCapability("deviceOrientation", orientation == DeviceOrientation.Portrait ? "portrait" : "landscape"); caps.SetCapability("username", username); caps.SetCapability("accessKey", accessKey); caps.SetCapability("name", browserName + " - " + DateTime.Now.ToString("F")); caps.SetCapability("javascriptEnabled", true); caps.SetCapability("acceptSslCerts", true); caps.SetCapability("takesScreenshot", testSettings.LogScreenShots); return caps; } return null; }
/// <summary> /// Initializes DeviceOrientationEventArgs class /// </summary> /// <param name="orientation"></param> public DeviceOrientationEventArgs(DeviceOrientation orientation) { DeviceOrientation = orientation; }
public ExhibitRoutePreviewPage() { InitializeComponent(); orientation = DeviceOrientation.Undefined; }
public AppetizerPage() { InitializeComponent(); DesignMode.Initialize(this); orientation = DeviceOrientation.Undefined; }
private void onDeviceOrientationChange(DeviceOrientation orientation) { determineOrientation(orientation); }
/// <summary> /// Gets the multi browser emulator web driver. /// </summary> /// <param name="testSettings">The test settings.</param> /// <param name="emulator">The emulator.</param> /// <param name="orientation">The device orientation.</param> /// <param name="testOutputHelper">The test output helper.</param> /// <returns></returns> public static ITestWebDriver InitializeMultiBrowserEmulatorDriver(TestSettings testSettings, Emulator emulator, DeviceOrientation orientation, ITestOutputHelper testOutputHelper) { ScreenShotCounter = 0; TestOutputHelper = testOutputHelper; testSettings.BrowserName = emulator + " " + orientation; testSettings = ValidateSavePaths(testSettings); //string driverLocation = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + // "\\MultiBrowser\\Drivers\\ChromeDrivers\\2.20\\chromedriver.exe"; string driverLocation = Path.Combine(AssemblyDirectory, "chromedriver.exe"); driverLocation = ValidateDriverPresentOrUnblocked(WebDriverType.ChromeDriver, driverLocation); var driverService = ChromeDriverService.CreateDefaultService(Path.GetDirectoryName(driverLocation), Path.GetFileName(driverLocation)); ValidateDriverPresentOrUnblocked(WebDriverType.ChromeDriver, driverLocation); var currentInstallPath = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\MultiBrowser", false) ?? Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432node\MultiBrowser", false); string installPathValue = null; if (currentInstallPath != null) { installPathValue = (string) currentInstallPath.GetValue("Path"); } if (installPathValue != null) { if (!installPathValue.EndsWith("\\")) { installPathValue = installPathValue + "\\"; } } #if DEBUG installPathValue = @"C:\Projects\MobileEmulator\bin\Debug\x64\"; #endif var options = new ChromeOptions { LeaveBrowserRunning = false, BinaryLocation = Path.Combine(installPathValue ?? @"C:\Program Files (x86)\MultiBrowser", "MultiBrowser Emulator.exe") }; var emulatorSettings = MultiBrowser.GetMultiBrowserEmulators(emulator); if (orientation == DeviceOrientation.Portrait) { var mobileEmulationSettings = new ChromeMobileEmulationDeviceSettings { UserAgent = emulatorSettings.DeviceUserAgent, Width = emulatorSettings.DeviceWidth, Height = emulatorSettings.DeviceHeight, EnableTouchEvents = true, PixelRatio = emulatorSettings.DevicePixelRatio }; options.EnableMobileEmulation(mobileEmulationSettings); //options.AddAdditionalCapability("mobileEmulation", new //{ // deviceMetrics = new // { // width = emulatorSettings.DeviceWidth, // height = emulatorSettings.DeviceHeight, // pixelRatio = emulatorSettings.DevicePixelRatio // }, // userAgent = emulatorSettings.DeviceUserAgent //}); } else { var mobileEmulationSettings = new ChromeMobileEmulationDeviceSettings { UserAgent = emulatorSettings.DeviceUserAgent, Width = emulatorSettings.DeviceHeight, Height = emulatorSettings.DeviceWidth, EnableTouchEvents = true, PixelRatio = emulatorSettings.DevicePixelRatio }; options.EnableMobileEmulation(mobileEmulationSettings); //options.AddAdditionalCapability("mobileEmulation", new //{ // deviceMetrics = new // { // width = emulatorSettings.DeviceHeight, // height = emulatorSettings.DeviceWidth, // pixelRatio = emulatorSettings.DevicePixelRatio // }, // userAgent = emulatorSettings.DeviceUserAgent //}); } #if DEBUG options.BinaryLocation = @"C:\Projects\MobileEmulator\bin\Debug\x64\MultiBrowser Emulator.exe"; #endif string authServerWhitelist = "auth-server-whitelist=" + testSettings.TestUri.Authority.Replace("www", "*"); string startUrl = "startUrl=" + testSettings.TestUri.AbsoluteUri; string selectedEmulator = "emulator=" + emulatorSettings.EmulatorArgument; var argsToPass = new[] { "test-type", "start-maximized", "no-default-browser-check", "allow-no-sandbox-job", "disable-component-update", "disable-translate", "disable-hang-monitor", authServerWhitelist, startUrl, selectedEmulator }; options.AddArguments(argsToPass); var driver = new ChromeDriver(driverService, options, testSettings.TimeoutTimeSpan); if (testSettings.DeleteAllCookies) { driver.Manage().Cookies.DeleteAllCookies(); } driver.Manage().Timeouts().ImplicitlyWait(testSettings.TimeoutTimeSpan); var extendedWebDriver = new TestWebDriver(driver, testSettings, TestOutputHelper); TestWebDriver = extendedWebDriver; return extendedWebDriver; }
internal async void ExecuteActionsIfRequired(VisualElement vsElement, double newScreenWidth, double newScreenHeight, DeviceOrientation newOrientation) { if (Actions == null) { throw new InvalidOperationException($"{nameof(Actions)} may not be null"); } bool wasValid = isValid; isValid = (Orientation == null || Orientation == newOrientation) && (MaxWidth == null || newScreenWidth <= MaxWidth) && (MinWidth == null || newScreenWidth >= MinWidth) && (MaxHeight == null || newScreenHeight <= MaxHeight) && (MinHeight == null || newScreenHeight >= MinHeight); if (isValid && !wasValid) { foreach (var action in Actions) { await Task.Yield(); action.InvokeAction(vsElement); } } }
/// <summary> /// Sets the dashboard OpenFeint orientation. /// </summary> /// <param name='orientation'> /// Orientation to set to. /// </param> public static void SetDashboardOrientation(DeviceOrientation orientation) { ArrayList args = new ArrayList { (int)orientation }; SendMessage("setDashboardOrientation", args); }
public DrawPrimitivesBase(DeviceOrientation orientation) : base(orientation) { }
public LoadingPage() { InitializeComponent(); deviceOrientation = DeviceOrientation.Undefined; }
public static bool IsPortrait(this DeviceOrientation orientation) { return(orientation == DeviceOrientation.Portrait || orientation == DeviceOrientation.PortraitDown || orientation == DeviceOrientation.PortraitUp); }
void Button_Clicked(System.Object sender, System.EventArgs e) { DeviceOrientation orientation = DependencyService.Get <IDeviceOrientationService>().GetOrientation(); orientationLabel.Text = orientation.ToString(); }
private void OnOrient(DeviceOrientation orientation) { device.Call(@"setOrientation", (int)orientation); }
public FageScreenEvent(DeviceOrientation lastOrientation, DeviceOrientation currentOrientation) : base(ORIENTATION) { this.lastOrientation = lastOrientation; this.currentOrientation = currentOrientation; }
public void RunMultiBrowserEmulatorTests(Emulator emulator, DeviceOrientation orientation) { _testSettings.TestType = TestType.EmulatorBrowser; _testSettings.DriverType = WebDriverType.ChromeDriver; _testSettings.TestDirectory = _testSettings.TestDirectory + "\\Emulator Browsers\\"; _driver = WebDriverManager.InitializeMultiBrowserEmulatorDriver(_testSettings, emulator, orientation, _testOutputHelper); if (_driver == null) { throw new NullReferenceException("_driver cannot be null"); } PerformTest(); _driver.Close(); }
public static void SetGlobalOrientation(DeviceOrientation orientation) { if (isSupportedPlatform) _SetGlobalOrientation((int)orientation); }
public static bool IsPortrait(this DeviceOrientation value) => (value == DeviceOrientation.Portrait) || (value == DeviceOrientation.PortraitUpsideDown);
// Camera size calculations copied from http://forum.unity3d.com/threads/android-resolutions.211905/ void SetupCamera() { float TARGET_WIDTH = 1280.0f; float TARGET_HEIGHT = 800.0f; int PIXELS_TO_UNITS = 80; float desiredRatio = TARGET_WIDTH / TARGET_HEIGHT; float currentRatio = (float)Screen.width/(float)Screen.height; if(currentRatio >= desiredRatio) { // Our resolution has plenty of width, so we just need to use the height to determine the camera size Camera.main.orthographicSize = TARGET_HEIGHT / 2 / PIXELS_TO_UNITS; } else { // Our camera needs to zoom out further than just fitting in the height of the image. // Determine how much bigger it needs to be, then apply that to our original algorithm. float differenceInSize = desiredRatio / currentRatio; Camera.main.orthographicSize = TARGET_HEIGHT / 2 / PIXELS_TO_UNITS * differenceInSize; } if (Screen.height < Screen.width) currentOrientation = DeviceOrientation.LandscapeLeft; else currentOrientation = DeviceOrientation.Portrait; }
public static OrientationStateTrigger Orientation(this OrientationStateTrigger trigger, DeviceOrientation orientation) { trigger.Orientation = orientation; return(trigger); }
public static bool IsLandscape(this DeviceOrientation value) => !value.IsPortrait();
private void OnEnable() { _instance = this; _currentRotation = Input.deviceOrientation; }
private void _InitDrawData() { _oldOrientation = Input.deviceOrientation; switch (_oldOrientation) { case DeviceOrientation.Portrait: _rotateAngle = 90; break; case DeviceOrientation.PortraitUpsideDown: _rotateAngle = 270; break; case DeviceOrientation.LandscapeRight: if (!isMirrored) _rotateAngle = 180; else _rotateAngle = 0; break; case DeviceOrientation.LandscapeLeft: default: if (!isMirrored) _rotateAngle = 0; else _rotateAngle = 180; _oldOrientation = DeviceOrientation.LandscapeLeft; break; } _oldScreenWidth = Screen.width; _cameraWidth = requestedCameraWidth; if (_cameraWidth == -1) _cameraWidth = Screen.width; _cameraHeight = requestedCameraHeight; if (_cameraHeight == -1) _cameraHeight = Screen.height; // always get the wider ratio for camera if (_cameraWidth < _cameraHeight) { int temp = _cameraWidth; _cameraWidth = _cameraHeight; _cameraHeight = temp; } float projectedWidth = projectedRect.width; if (projectedWidth == -1) projectedWidth = Screen.width; float projectedHeight = projectedRect.height; if (projectedHeight == -1) projectedHeight = Screen.height; _drawRect = new Rect(projectedRect.x, projectedRect.y, projectedWidth, projectedHeight); _pivot = new Vector2(_drawRect.xMin + _drawRect.width * 0.5f, _drawRect.yMin + _drawRect.height * 0.5f); Debug.Log("Orientation: " + _oldOrientation + "\ndetector orientation: " + cameraOrientationForFaceDetector + "\nscreen size: " + Screen.width + "x" + Screen.height + "\nprojected size: " + projectedWidth + "x" + projectedHeight + "\nCamera requested size: " + _cameraWidth + "x" + _cameraHeight + "\nDraw rect: " + _drawRect ); }