Ejemplo n.º 1
0
        private void UpdateOverridePlayerSettingsStatus()
        {
            var buildTargetGroup = BuildTargetGroup.Unknown;
            var buildTarget      = BuildTarget.NoTarget;

            if (m_DeviceInfo.IsAndroidDevice())
            {
                buildTargetGroup = BuildTargetGroup.Android;
                buildTarget      = BuildTarget.Android;
            }
            else if (m_DeviceInfo.IsiOSDevice())
            {
                buildTargetGroup = BuildTargetGroup.iOS;
                buildTarget      = BuildTarget.iOS;
            }

            bool isTargetSupported = BuildPipeline.IsBuildTargetSupported(buildTargetGroup, buildTarget);

            if (isTargetSupported)
            {
                m_OverrideDefaultPlayerSettings.SetEnabled(true);
            }
            else
            {
                m_OverrideDefaultPlayerSettings.SetEnabled(false);
                m_OverrideDefaultPlayerSettings.SetValueWithoutNotify(true);
            }
        }
Ejemplo n.º 2
0
        // Insets are parts of the screen that are outside of unity rendering area, like navigation bar in windowed mode. Insets are only possible on Android at the moment.
        private void CalculateInsets()
        {
            if (!m_DeviceInfo.IsAndroidDevice())
            {
                return;
            }

            var inset = Vector4.zero;

            if (!m_IsFullScreen)
            {
                switch (m_RenderedOrientation)
                {
                case ScreenOrientation.Portrait:
                case ScreenOrientation.LandscapeLeft:
                case ScreenOrientation.LandscapeRight:
                    inset = new Vector4(0, m_Screen.height - m_SupportedOrientations[ScreenOrientation.Portrait].safeArea.height, 0, m_Screen.navigationBarHeight);
                    break;

                case ScreenOrientation.PortraitUpsideDown:
                    var topInset = m_Screen.height - m_SupportedOrientations[ScreenOrientation.Portrait].safeArea.height + m_Screen.navigationBarHeight;
                    inset = new Vector4(0, topInset, 0, 0);
                    break;
                }
            }
            Insets = inset;
            OnInsetsChanged?.Invoke(inset);
        }
Ejemplo n.º 3
0
        public SystemInfoSimulation(DeviceInfo deviceInfo, SimulationPlayerSettings playerSettings, List <string> shimmedAssemblies)
        {
            m_ShimmedAssemblies = shimmedAssemblies;

            m_DeviceInfo = deviceInfo;
            if (m_DeviceInfo?.SystemInfo?.graphicsDependentData?.Length > 0)
            {
                if (deviceInfo.IsAndroidDevice())
                {
                    m_GraphicsDeviceType = (
                        from selected in playerSettings.androidGraphicsAPIs
                        from device in m_DeviceInfo.SystemInfo.graphicsDependentData
                        where selected == device.graphicsDeviceType select device).FirstOrDefault();
                }
                else if (deviceInfo.IsiOSDevice())
                {
                    m_GraphicsDeviceType = (
                        from selected in playerSettings.iOSGraphicsAPIs
                        from device in m_DeviceInfo.SystemInfo.graphicsDependentData
                        where selected == device.graphicsDeviceType select device).FirstOrDefault();
                }
                if (m_GraphicsDeviceType == null)
                {
                    Debug.LogWarning("Could not pick GraphicsDeviceType, the game would fail to launch");
                }
            }
            Enable();
        }
Ejemplo n.º 4
0
        public SystemInfoSimulation(DeviceInfo deviceInfo, SimulationPlayerSettings playerSettings, List <string> shimmedAssemblies)
        {
            const string dll = ".dll";

            m_ShimmedAssemblies = shimmedAssemblies;
            m_ShimmedAssemblies.RemoveAll(string.IsNullOrEmpty);

            for (int i = 0; i < m_ShimmedAssemblies.Count; i++)
            {
                m_ShimmedAssemblies[i] = m_ShimmedAssemblies[i].ToLower();
                if (!m_ShimmedAssemblies[i].EndsWith(dll))
                {
                    m_ShimmedAssemblies[i] += dll;
                }
            }

            m_DeviceInfo = deviceInfo;
            if (m_DeviceInfo?.SystemInfo?.GraphicsDependentData?.Length > 0)
            {
                if (deviceInfo.IsAndroidDevice())
                {
                    m_GraphicsDeviceType = (
                        from selected in playerSettings.androidGraphicsAPIs
                        from device in m_DeviceInfo.SystemInfo.GraphicsDependentData
                        where selected == device.graphicsDeviceType select device).FirstOrDefault();
                }
                else if (deviceInfo.IsiOSDevice())
                {
                    m_GraphicsDeviceType = (
                        from selected in playerSettings.iOSGraphicsAPIs
                        from device in m_DeviceInfo.SystemInfo.GraphicsDependentData
                        where selected == device.graphicsDeviceType select device).FirstOrDefault();
                }
                if (m_GraphicsDeviceType == null)
                {
                    Debug.LogWarning("Could not pick GraphicsDeviceType, the game would fail to launch");
                }
            }
            Enable();
        }
Ejemplo n.º 5
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);
        }