Esempio n. 1
0
 public void AddOptionalFields()
 {
     foreach (var screen in Screens)
     {
         if (screen.orientations == null || screen.orientations.Length == 0)
         {
             screen.orientations = new[]
             {
                 new OrientationData {
                     orientation = ScreenOrientation.Portrait
                 },
                 new OrientationData {
                     orientation = ScreenOrientation.PortraitUpsideDown
                 },
                 new OrientationData {
                     orientation = ScreenOrientation.LandscapeLeft
                 },
                 new OrientationData {
                     orientation = ScreenOrientation.LandscapeRight
                 }
             };
         }
         foreach (var orientation in screen.orientations)
         {
             if (orientation.safeArea == Rect.zero)
             {
                 orientation.safeArea = SimulatorUtilities.IsLandscape(orientation.orientation) ? new Rect(0, 0, screen.height, screen.width) : new Rect(0, 0, screen.width, screen.height);
             }
         }
     }
 }
Esempio n. 2
0
        private Quaternion ComputeRotationForHighlightSafeArea()
        {
            var rotation = Quaternion.identity;

            // We have to consider the case that the rendering orientation is not same as the physical orientation.
            var physicalOrientation = SimulatorUtilities.RotationToScreenOrientation(m_Rotation);

            switch (TargetOrientation)
            {
            case ScreenOrientation.Portrait:
            case ScreenOrientation.PortraitUpsideDown:
                if (SimulatorUtilities.IsLandscape(physicalOrientation))
                {
                    rotation = Quaternion.Euler(0, 0, 90);
                }
                break;

            case ScreenOrientation.LandscapeLeft:
            case ScreenOrientation.LandscapeRight:
                if (!SimulatorUtilities.IsLandscape(physicalOrientation))
                {
                    rotation = Quaternion.Euler(0, 0, 90);
                }
                break;
            }

            return(rotation);
        }
Esempio n. 3
0
        private void DrawPreviewImage(MeshGenerationContext mgc)
        {
            if (m_PreviewImage == null)
            {
                return;
            }

            ComputePreviewImageHalfSizeAndOffset(out Vector2 halfSize, out Vector2 offset);

            var meshWriteData = mgc.Allocate(4, 6, m_PreviewImage, m_PreviewMaterial, MeshGenerationContext.MeshFlags.None);

            var vertices = new Vertex[4];

            vertices[0].position = new Vector3(-halfSize.x, -halfSize.y, Vertex.nearZ);
            vertices[0].tint     = Color.white;

            vertices[1].position = new Vector3(halfSize.x, -halfSize.y, Vertex.nearZ);
            vertices[1].tint     = Color.white;

            vertices[2].position = new Vector3(halfSize.x, halfSize.y, Vertex.nearZ);
            vertices[2].tint     = Color.white;

            vertices[3].position = new Vector3(-halfSize.x, halfSize.y, Vertex.nearZ);
            vertices[3].tint     = Color.white;

            SimulatorUtilities.SetTextureCoordinates(TargetOrientation, vertices);
            SimulatorUtilities.TransformVertices(m_Rotation, offset, vertices);

            meshWriteData.SetAllVertices(vertices);

            var indices = new ushort[] { 0, 3, 1, 1, 3, 2 };

            meshWriteData.SetAllIndices(indices);
        }
        private void RenderPreviewImage()
        {
            if (PreviewTexture == null)
            {
                return;
            }

            ComputePreviewImageHalfSizeAndOffset(out Vector2 halfSize, out Vector2 offset);

            var vertices = new Vector3[4];

            vertices[0] = new Vector3(-halfSize.x, -halfSize.y, zValue);
            vertices[1] = new Vector3(halfSize.x, -halfSize.y, zValue);
            vertices[2] = new Vector3(halfSize.x, halfSize.y, zValue);
            vertices[3] = new Vector3(-halfSize.x, halfSize.y, zValue);

            var uvs = new Vector2[4];

            SimulatorUtilities.SetTextureCoordinates(TargetOrientation, uvs);

            var mesh = new Mesh()
            {
                vertices  = vertices,
                uv        = uvs,
                triangles = new[] { 0, 1, 3, 1, 2, 3 }
            };

            m_PreviewMaterial.mainTexture = PreviewTexture;
            m_PreviewMaterial.SetPass(0);

            var transformMatrix = Matrix4x4.TRS(new Vector3(offset.x, offset.y), m_Rotation, Vector3.one);

            Graphics.DrawMeshNow(mesh, transformMatrix);
        }
Esempio n. 5
0
        private void DrawHighlightSafeArea(MeshGenerationContext mgc)
        {
            if (!m_HighlightSafeArea)
            {
                return;
            }

            var safeAreaInScreen = GetSafeAreaInScreen();
            var halfImageWidth   = safeAreaInScreen.width / 2;
            var halfImageHeight  = safeAreaInScreen.height / 2;

            const int vertexCount = 8, indexCount = 24;
            var       meshWriteData = mgc.Allocate(vertexCount, indexCount);
            var       vertices      = new Vertex[vertexCount];

            var       highlightColor     = Color.green;
            const int highlightLineWidth = 2;

            vertices[0].position = new Vector3(-halfImageWidth, -halfImageHeight, Vertex.nearZ);
            vertices[0].tint     = highlightColor;

            vertices[1].position = new Vector3(halfImageWidth, -halfImageHeight, Vertex.nearZ);
            vertices[1].tint     = highlightColor;

            vertices[2].position = new Vector3(halfImageWidth, halfImageHeight, Vertex.nearZ);
            vertices[2].tint     = highlightColor;

            vertices[3].position = new Vector3(-halfImageWidth, halfImageHeight, Vertex.nearZ);
            vertices[3].tint     = highlightColor;

            vertices[4].position = new Vector3(-halfImageWidth + highlightLineWidth, -halfImageHeight + highlightLineWidth, Vertex.nearZ);
            vertices[4].tint     = highlightColor;

            vertices[5].position = new Vector3(halfImageWidth - highlightLineWidth, -halfImageHeight + highlightLineWidth, Vertex.nearZ);
            vertices[5].tint     = highlightColor;

            vertices[6].position = new Vector3(halfImageWidth - highlightLineWidth, halfImageHeight - highlightLineWidth, Vertex.nearZ);
            vertices[6].tint     = highlightColor;

            vertices[7].position = new Vector3(-halfImageWidth + highlightLineWidth, halfImageHeight - highlightLineWidth, Vertex.nearZ);
            vertices[7].tint     = highlightColor;

            var offset = new Vector2(m_Offset.x + safeAreaInScreen.x / 2, m_Offset.y + safeAreaInScreen.y / 2);

            offset = ComputeOffsetForScreenMode(offset, true);

            SimulatorUtilities.TransformVertices(ComputeRotationForHighlightSafeArea(), offset, vertices);

            meshWriteData.SetAllVertices(vertices);

            var indices = new ushort[]
            {
                0, 4, 1, 1, 4, 5, 1, 5, 6, 1, 6, 2, 6, 7, 2, 7, 3, 2, 0, 3, 4, 3, 7, 4
            };

            meshWriteData.SetAllIndices(indices);
        }
Esempio n. 6
0
 private void Rotate(Quaternion rotation)
 {
     if (m_AutoRotation)
     {
         var newOrientation = SimulatorUtilities.RotationToScreenOrientation(rotation);
         if (m_Screen.orientations.ContainsKey(newOrientation) && m_AllowedAutoRotation[newOrientation])
         {
             ForceNewOrientation(newOrientation);
         }
         OnOrientationChanged?.Invoke(m_AutoRotation);
     }
 }
Esempio n. 7
0
        private void DrawDeviceImage(MeshGenerationContext mgc)
        {
            if (m_DeviceInfo.Meta.overlayImage == null)
            {
                DrawDeviceBorder(mgc);
                return;
            }

            var scale           = m_Scale / 100f;
            var halfImageWidth  = scale * m_DeviceInfo.Screens[0].width / 2;
            var halfImageHeight = scale * m_DeviceInfo.Screens[0].height / 2;

            var leftWidth   = halfImageWidth + scale * m_DeviceInfo.Meta.overlayOffset.x;
            var topWidth    = halfImageHeight + scale * m_DeviceInfo.Meta.overlayOffset.y;
            var rightWidth  = halfImageWidth + scale * m_DeviceInfo.Meta.overlayOffset.z;
            var bottomWidth = halfImageHeight + scale * m_DeviceInfo.Meta.overlayOffset.w;

            var meshWriteData = mgc.Allocate(4, 6, m_DeviceInfo.Meta.overlayImage);

            var vertices = new Vertex[4];

            vertices[0].position = new Vector3(-leftWidth, -topWidth, Vertex.nearZ);
            vertices[0].tint     = Color.white;
            vertices[0].uv       = new Vector2(0, 1);

            vertices[1].position = new Vector3(rightWidth, -topWidth, Vertex.nearZ);
            vertices[1].tint     = Color.white;
            vertices[1].uv       = new Vector2(1, 1);

            vertices[2].position = new Vector3(rightWidth, bottomWidth, Vertex.nearZ);
            vertices[2].tint     = Color.white;
            vertices[2].uv       = new Vector2(1, 0);

            vertices[3].position = new Vector3(-leftWidth, bottomWidth, Vertex.nearZ);
            vertices[3].tint     = Color.white;
            vertices[3].uv       = new Vector2(0, 0);

            SimulatorUtilities.TransformVertices(m_Rotation, m_Offset, vertices);

            meshWriteData.SetAllVertices(vertices);

            var indices = new ushort[] { 0, 3, 1, 1, 3, 2 };

            meshWriteData.SetAllIndices(indices);
        }
Esempio n. 8
0
        private void Rotate(Quaternion rotation)
        {
            if (!m_AutoRotation)
            {
                return;
            }

            var newOrientation = SimulatorUtilities.RotationToScreenOrientation(rotation);

            if (newOrientation != m_RenderedOrientation && m_SupportedOrientations.ContainsKey(newOrientation) && m_AllowedAutoRotation[newOrientation])
            {
                ForceNewOrientation(newOrientation);
            }
            else
            {
                OnOrientationChanged?.Invoke(m_AutoRotation);
            }
        }
Esempio n. 9
0
        private Rect GetSafeAreaInScreen()
        {
            var sa = m_DeviceInfo.Screens[0].orientations[TargetOrientation].safeArea;

            if (!IsFullScreen)
            {
                if (SimulatorUtilities.IsLandscape(TargetOrientation))
                {
                    sa.width -= m_DeviceInfo.Screens[0].navigationBarHeight;
                }
                else
                {
                    sa.height -= m_DeviceInfo.Screens[0].navigationBarHeight;
                }
            }

            var scale = m_Scale / 100f;

            return(new Rect(0, 0, sa.width * scale, sa.height * scale));
        }
Esempio n. 10
0
        public ScreenSimulation(DeviceInfo device, IInputProvider inputProvider, SimulationPlayerSettings playerSettings)
        {
            m_DeviceInfo = device;
            m_Screen     = device.Screens[0];

            m_InputProvider             = inputProvider;
            m_InputProvider.OnRotation += Rotate;

            m_SupportedOrientations = new Dictionary <ScreenOrientation, OrientationData>();
            foreach (var o in m_Screen.orientations)
            {
                m_SupportedOrientations.Add(o.orientation, o);
            }

            m_AllowedAutoRotation = new Dictionary <ScreenOrientation, bool>();
            m_AllowedAutoRotation.Add(ScreenOrientation.Portrait, playerSettings.allowedPortrait);
            m_AllowedAutoRotation.Add(ScreenOrientation.PortraitUpsideDown, playerSettings.allowedPortraitUpsideDown);
            m_AllowedAutoRotation.Add(ScreenOrientation.LandscapeLeft, playerSettings.allowedLandscapeLeft);
            m_AllowedAutoRotation.Add(ScreenOrientation.LandscapeRight, playerSettings.allowedLandscapeRight);

            // Set the full screen mode.
            m_IsFullScreen = !m_DeviceInfo.IsAndroidDevice() || playerSettings.androidStartInFullscreen;

            // Calculate the right orientation.
            var settingOrientation = SimulatorUtilities.ToScreenOrientation(playerSettings.defaultOrientation);

            if (settingOrientation == ScreenOrientation.AutoRotation)
            {
                m_AutoRotation = true;
                var newOrientation = SimulatorUtilities.RotationToScreenOrientation(m_InputProvider.Rotation);
                if (m_SupportedOrientations.ContainsKey(newOrientation) && m_AllowedAutoRotation[newOrientation])
                {
                    ForceNewOrientation(newOrientation);
                }
                else
                {
                    SetFirstAvailableAutoOrientation();
                }
            }
            else if (m_SupportedOrientations.ContainsKey(settingOrientation))
            {
                m_AutoRotation = false;
                ForceNewOrientation(settingOrientation);
            }
            else
            {
                // At least iPhone X responds to this absolute corner case by crashing, we will not do that.
                m_AutoRotation = false;
                ForceNewOrientation(m_SupportedOrientations.Keys.ToArray()[0]);
            }

            // Calculate the right resolution.
            var initWidth  = m_Screen.width;
            var initHeight = m_Screen.height;

            if (playerSettings.resolutionScalingMode == ResolutionScalingMode.FixedDpi && playerSettings.targetDpi < m_Screen.dpi)
            {
                m_DpiRatio = playerSettings.targetDpi / m_Screen.dpi;
                initWidth  = (int)(initWidth * m_DpiRatio);
                initHeight = (int)(initHeight * m_DpiRatio);
            }
            m_CurrentWidth  = IsRenderingLandscape ? initHeight : initWidth;
            m_CurrentHeight = IsRenderingLandscape ? initWidth : initHeight;

            if (!m_IsFullScreen)
            {
                CalculateScreenResolutionForScreenMode(out m_CurrentWidth, out m_CurrentHeight);
                CalculateInsets();
            }
            CalculateSafeAreaAndCutouts();

            ShimManager.UseShim(this);
        }
Esempio n. 11
0
        private void ComputeBoundingBox()
        {
            var overlayOffset  = m_DeviceInfo.Meta.overlayOffset;
            var width          = m_DeviceInfo.Screens[0].width + overlayOffset.x + overlayOffset.z;
            var height         = m_DeviceInfo.Screens[0].height + overlayOffset.y + overlayOffset.w;
            var toScreenCenter = new Vector2(m_DeviceInfo.Screens[0].width / 2 + overlayOffset.x, m_DeviceInfo.Screens[0].height / 2 + overlayOffset.y);

            var vertices = new Vector3[4];

            vertices[0] = new Vector3(0, 0, Vertex.nearZ);
            vertices[1] = new Vector3(width, 0, Vertex.nearZ);
            vertices[2] = new Vector3(width, height, Vertex.nearZ);
            vertices[3] = new Vector3(0, height, Vertex.nearZ);

            var       scale           = m_Scale / 100f;
            Matrix4x4 transformMatrix = Matrix4x4.TRS(
                new Vector3(0, 0, 0), m_Rotation, new Vector3(scale, scale));

            for (int index = 0; index < vertices.Length; ++index)
            {
                vertices[index] = transformMatrix.MultiplyPoint(vertices[index]);
            }

            var min = new Vector2(float.MaxValue, float.MaxValue);
            var max = new Vector2(float.MinValue, float.MinValue);

            foreach (var vertex in vertices)
            {
                if (vertex.x < min.x)
                {
                    min.x = vertex.x;
                }
                if (vertex.x > max.x)
                {
                    max.x = vertex.x;
                }

                if (vertex.y < min.y)
                {
                    min.y = vertex.y;
                }
                if (vertex.y > max.y)
                {
                    max.y = vertex.y;
                }
            }

            m_BoundingBox = max - min;
            m_Offset      = m_BoundingBox / 2;

            // We need to consider the case that overlay offset is not symmetrical.
            var physicalOrientation = SimulatorUtilities.RotationToScreenOrientation(m_Rotation);

            switch (physicalOrientation)
            {
            case ScreenOrientation.Portrait:
                m_Offset.x -= (overlayOffset.z - overlayOffset.x) * scale / 2;
                m_Offset.y -= (overlayOffset.w - overlayOffset.y) * scale / 2;
                break;

            case ScreenOrientation.PortraitUpsideDown:
                m_Offset.x += (overlayOffset.z - overlayOffset.x) * scale / 2;
                m_Offset.y += (overlayOffset.w - overlayOffset.y) * scale / 2;
                break;

            case ScreenOrientation.Landscape:
                m_Offset.x -= (overlayOffset.w - overlayOffset.y) * scale / 2;
                m_Offset.y += (overlayOffset.z - overlayOffset.x) * scale / 2;
                break;

            case ScreenOrientation.LandscapeRight:
                m_Offset.x += (overlayOffset.w - overlayOffset.y) * scale / 2;
                m_Offset.y -= (overlayOffset.z - overlayOffset.x) * scale / 2;
                break;
            }

            // Device space: (0,0) at the left top corner of the device in portrait orientation, 1 unit is 1 screen pixel of the device screen
            var deviceSpaceToPreviewImageRendererSpace =
                Matrix4x4.TRS(new Vector3(m_Offset.x, m_Offset.y), m_Rotation, new Vector3(scale, scale, 1)) *
                Matrix4x4.Translate(new Vector3(-toScreenCenter.x, -toScreenCenter.y, 0));
            var deviceSpaceToScreenSpace = Matrix4x4.Translate(new Vector3(-overlayOffset.x, -overlayOffset.y));

            m_TouchEventManipulator.PreviewImageRendererSpaceToScreenSpace = deviceSpaceToScreenSpace * deviceSpaceToPreviewImageRendererSpace.inverse;

            m_PreviewImageRenderer.style.width  = m_BoundingBox.x;
            m_PreviewImageRenderer.style.height = m_BoundingBox.y;
        }
Esempio n. 12
0
        private void DrawDeviceBorder(MeshGenerationContext mgc)
        {
            // For now, we draw device as borders. We can draw device image in the future.
            var scale           = m_Scale / 100f;
            var halfImageWidth  = scale * m_DeviceInfo.Screens[0].width / 2;
            var halfImageHeight = scale * m_DeviceInfo.Screens[0].height / 2;

            var leftOuterWidth   = halfImageWidth + scale * m_DeviceInfo.Meta.overlayOffset.x;
            var topOuterWidth    = halfImageHeight + scale * m_DeviceInfo.Meta.overlayOffset.y;
            var rightOuterWidth  = halfImageWidth + scale * m_DeviceInfo.Meta.overlayOffset.z;
            var bottomOuterWidth = halfImageHeight + scale * m_DeviceInfo.Meta.overlayOffset.w;

            var padding          = 20 * scale;
            var leftInnerWidth   = leftOuterWidth - padding;
            var topInnerWidth    = topOuterWidth - padding;
            var rightInnerWidth  = rightOuterWidth - padding;
            var bottomInnerWidth = bottomOuterWidth - padding;

            var outerColor = EditorGUIUtility.isProSkin ? new Color(217f / 255, 217f / 255, 217f / 255) : new Color(100f / 255, 100f / 255, 100f / 255);
            var innerColor = new Color(41f / 255, 41f / 255, 41f / 255);

            const int vertexCount = 16, indexCount = 48;
            var       meshWriteData = mgc.Allocate(vertexCount, indexCount);
            var       vertices      = new Vertex[vertexCount];

            // Outer border.
            vertices[0].position = new Vector3(-leftOuterWidth, -topOuterWidth, Vertex.nearZ);
            vertices[0].tint     = outerColor;

            vertices[1].position = new Vector3(rightOuterWidth, -topOuterWidth, Vertex.nearZ);
            vertices[1].tint     = outerColor;

            vertices[2].position = new Vector3(rightOuterWidth, bottomOuterWidth, Vertex.nearZ);
            vertices[2].tint     = outerColor;

            vertices[3].position = new Vector3(-leftOuterWidth, bottomOuterWidth, Vertex.nearZ);
            vertices[3].tint     = outerColor;

            vertices[4].position = new Vector3(-leftInnerWidth, -topInnerWidth, Vertex.nearZ);
            vertices[4].tint     = outerColor;

            vertices[5].position = new Vector3(rightInnerWidth, -topInnerWidth, Vertex.nearZ);
            vertices[5].tint     = outerColor;

            vertices[6].position = new Vector3(rightInnerWidth, bottomInnerWidth, Vertex.nearZ);
            vertices[6].tint     = outerColor;

            vertices[7].position = new Vector3(-leftInnerWidth, bottomInnerWidth, Vertex.nearZ);
            vertices[7].tint     = outerColor;

            //Inner border.
            vertices[8].position = vertices[4].position;
            vertices[8].tint     = innerColor;

            vertices[9].position = vertices[5].position;
            vertices[9].tint     = innerColor;

            vertices[10].position = vertices[6].position;
            vertices[10].tint     = innerColor;

            vertices[11].position = vertices[7].position;
            vertices[11].tint     = innerColor;

            vertices[12].position = new Vector3(-halfImageWidth, -halfImageHeight, Vertex.nearZ);
            vertices[12].tint     = innerColor;

            vertices[13].position = new Vector3(halfImageWidth, -halfImageHeight, Vertex.nearZ);
            vertices[13].tint     = innerColor;

            vertices[14].position = new Vector3(halfImageWidth, halfImageHeight, Vertex.nearZ);
            vertices[14].tint     = innerColor;

            vertices[15].position = new Vector3(-halfImageWidth, halfImageHeight, Vertex.nearZ);
            vertices[15].tint     = innerColor;

            SimulatorUtilities.TransformVertices(m_Rotation, m_Offset, vertices);

            meshWriteData.SetAllVertices(vertices);

            var indices = new ushort[]
            {
                0, 4, 1, 1, 4, 5, 1, 5, 6, 1, 6, 2, 6, 7, 2, 7, 3, 2, 0, 3, 4, 3, 7, 4,                  // Outer
                8, 12, 9, 9, 12, 13, 9, 13, 14, 9, 14, 10, 14, 15, 10, 15, 11, 10, 8, 11, 12, 11, 15, 12 // Inner
            };

            meshWriteData.SetAllIndices(indices);
        }
Esempio n. 13
0
        private Vector2 ComputeOffsetForScreenMode(Vector2 offset, bool isHighlightingSafeArea = false)
        {
            // If we're rendering the preview image in full screen mode, no extra offset.
            if (IsFullScreen && !isHighlightingSafeArea)
            {
                return(offset);
            }

            var scale = m_Scale / 100f;
            var scaledNavigationBarOffset = (IsFullScreen && isHighlightingSafeArea) ? 0 : m_DeviceInfo.Screens[0].navigationBarHeight * scale / 2.0f;

            var safeArea       = m_DeviceInfo.Screens[0].orientations[TargetOrientation].safeArea;
            var safeAreaOffset = new Vector2(safeArea.x + safeArea.width / 2.0f, safeArea.y + safeArea.height / 2.0f);

            if (SimulatorUtilities.IsLandscape(TargetOrientation))
            {
                safeAreaOffset.x -= m_DeviceInfo.Screens[0].height / 2.0f;
                safeAreaOffset.y -= m_DeviceInfo.Screens[0].width / 2.0f;
            }
            else
            {
                safeAreaOffset.x -= m_DeviceInfo.Screens[0].width / 2.0f;
                safeAreaOffset.y -= m_DeviceInfo.Screens[0].height / 2.0f;
            }

            var scaledSafeAreaOffset = scale * safeAreaOffset;
            var tempOffset           = offset;

            // We have to consider the case that the rendering orientation is not same as the physical orientation.
            var physicalOrientation = SimulatorUtilities.RotationToScreenOrientation(m_Rotation);

            switch (TargetOrientation)
            {
            case ScreenOrientation.Portrait:
                switch (physicalOrientation)
                {
                case ScreenOrientation.Portrait:
                    tempOffset.x = tempOffset.x + scaledSafeAreaOffset.x;
                    tempOffset.y = tempOffset.y - scaledSafeAreaOffset.y - scaledNavigationBarOffset;
                    break;

                case ScreenOrientation.PortraitUpsideDown:
                    tempOffset.x = tempOffset.x + scaledSafeAreaOffset.x;
                    tempOffset.y = tempOffset.y + scaledSafeAreaOffset.y + scaledNavigationBarOffset;
                    break;

                case ScreenOrientation.LandscapeLeft:
                    tempOffset.x = tempOffset.x - scaledSafeAreaOffset.y - scaledNavigationBarOffset;
                    tempOffset.y = tempOffset.y + scaledSafeAreaOffset.x;
                    break;

                case ScreenOrientation.LandscapeRight:
                    tempOffset.x = tempOffset.x + scaledSafeAreaOffset.y + scaledNavigationBarOffset;
                    tempOffset.y = tempOffset.y + scaledSafeAreaOffset.x;
                    break;
                }
                break;

            case ScreenOrientation.PortraitUpsideDown:
                switch (physicalOrientation)
                {
                case ScreenOrientation.Portrait:
                    tempOffset.x = tempOffset.x + scaledSafeAreaOffset.x;
                    tempOffset.y = tempOffset.y + scaledSafeAreaOffset.y + scaledNavigationBarOffset;
                    break;

                case ScreenOrientation.PortraitUpsideDown:
                    tempOffset.x = tempOffset.x + scaledSafeAreaOffset.x;
                    tempOffset.y = tempOffset.y - scaledSafeAreaOffset.y - scaledNavigationBarOffset;
                    break;

                case ScreenOrientation.LandscapeLeft:
                    tempOffset.x = tempOffset.x + scaledSafeAreaOffset.y + scaledNavigationBarOffset;
                    tempOffset.y = tempOffset.y + scaledSafeAreaOffset.x;
                    break;

                case ScreenOrientation.LandscapeRight:
                    tempOffset.x = tempOffset.x - scaledSafeAreaOffset.y - scaledNavigationBarOffset;
                    tempOffset.y = tempOffset.y + scaledSafeAreaOffset.x;
                    break;
                }
                break;

            case ScreenOrientation.LandscapeLeft:
                switch (physicalOrientation)
                {
                case ScreenOrientation.Portrait:
                    tempOffset.x = tempOffset.x + scaledSafeAreaOffset.y;
                    tempOffset.y = tempOffset.y + scaledSafeAreaOffset.x - scaledNavigationBarOffset;
                    break;

                case ScreenOrientation.PortraitUpsideDown:
                    tempOffset.x = tempOffset.x - scaledSafeAreaOffset.y;
                    tempOffset.y = tempOffset.y - scaledSafeAreaOffset.x + scaledNavigationBarOffset;
                    break;

                case ScreenOrientation.LandscapeLeft:
                    tempOffset.x = tempOffset.x + scaledSafeAreaOffset.x - scaledNavigationBarOffset;
                    tempOffset.y = tempOffset.y - scaledSafeAreaOffset.y;
                    break;

                case ScreenOrientation.LandscapeRight:
                    tempOffset.x = tempOffset.x - scaledSafeAreaOffset.x + scaledNavigationBarOffset;
                    tempOffset.y = tempOffset.y + scaledSafeAreaOffset.y;
                    break;
                }
                break;

            case ScreenOrientation.LandscapeRight:
                switch (physicalOrientation)
                {
                case ScreenOrientation.Portrait:
                    tempOffset.x = tempOffset.x - scaledSafeAreaOffset.y;
                    tempOffset.y = tempOffset.y - scaledSafeAreaOffset.x - scaledNavigationBarOffset;
                    break;

                case ScreenOrientation.PortraitUpsideDown:
                    tempOffset.x = tempOffset.x + scaledSafeAreaOffset.y;
                    tempOffset.y = tempOffset.y + scaledSafeAreaOffset.x + scaledNavigationBarOffset;
                    break;

                case ScreenOrientation.LandscapeLeft:
                    tempOffset.x = tempOffset.x - scaledSafeAreaOffset.x - scaledNavigationBarOffset;
                    tempOffset.y = tempOffset.y + scaledSafeAreaOffset.y;
                    break;

                case ScreenOrientation.LandscapeRight:
                    tempOffset.x = tempOffset.x + scaledSafeAreaOffset.x + scaledNavigationBarOffset;
                    tempOffset.y = tempOffset.y - scaledSafeAreaOffset.y;
                    break;
                }

                break;
            }

            return(tempOffset);
        }
Esempio n. 14
0
 private bool ShouldShim()
 {
     return(SimulatorUtilities.ShouldShim(m_ShimmedAssemblies));
 }