public SystemInfoSimulation(DeviceInfoAsset device, SimulationPlayerSettings playerSettings)
 {
     m_SystemInfo       = device.deviceInfo.systemInfo;
     m_SystemInfoFields = device.availableSystemInfoFields;
     if (device.deviceInfo.systemInfo.graphicsDependentData?.Length > 0)
     {
         if (device.deviceInfo.IsAndroidDevice())
         {
             m_GraphicsSystemInfo = (
                 from selected in playerSettings.androidGraphicsAPIs
                 from gfxDevice in m_SystemInfo.graphicsDependentData
                 where selected == gfxDevice.graphicsDeviceType select gfxDevice).FirstOrDefault();
         }
         else if (device.deviceInfo.IsiOSDevice())
         {
             m_GraphicsSystemInfo = (
                 from selected in playerSettings.iOSGraphicsAPIs
                 from gfxDevice in m_SystemInfo.graphicsDependentData
                 where selected == gfxDevice.graphicsDeviceType select gfxDevice).FirstOrDefault();
         }
         if (m_GraphicsSystemInfo == null)
         {
             Debug.LogWarning("Could not pick GraphicsDeviceType, the game would fail to launch");
         }
     }
     m_GraphicsSystemInfoFields = m_GraphicsSystemInfo != null ? device.availableGraphicsSystemInfoFields[m_GraphicsSystemInfo.graphicsDeviceType] : new HashSet <string>();
     Enable();
 }
示例#2
0
        public ScreenSimulation(DeviceInfo device, SimulationPlayerSettings playerSettings, int screenIndex)
        {
            m_PlayerSettings = playerSettings;
            m_DeviceInfo     = device;
            m_Screen         = device.screens[screenIndex];

            FindSupportedOrientations();

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

            // Set the full screen mode.
            m_IsFullScreen               = !m_DeviceInfo.IsAndroidDevice() || m_PlayerSettings.androidStartInFullscreen;
            m_RequestedFullScreen        = m_IsFullScreen;
            m_IsRenderingOutsideSafeArea = !m_DeviceInfo.IsAndroidDevice() || m_PlayerSettings.androidRenderOutsideSafeArea;

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

            if (settingOrientation == ScreenOrientation.AutoRotation)
            {
                m_AutoRotation = true;
                SetFirstAvailableAutoOrientation();
            }
            else if (m_SupportedOrientations.ContainsKey(settingOrientation))
            {
                m_AutoRotation = false;
                RequestOrientation(settingOrientation);
            }
            else
            {
                // The real iPhone X responds to this absolute corner case by crashing, we will not do that.
                m_AutoRotation = false;
                RequestOrientation(m_SupportedOrientations.Keys.ToArray()[0]);
            }

            m_RequestInsetUpdate       = true;
            m_RequestDefaultResolution = true;

            ShimManager.UseShim(this);
        }
        public ScreenSimulation(DeviceInfo device, SimulationPlayerSettings playerSettings)
        {
            m_DeviceInfo = device;
            m_Screen     = device.screens[0];

            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;
                SetFirstAvailableAutoOrientation();
            }
            else if (m_SupportedOrientations.ContainsKey(settingOrientation))
            {
                m_AutoRotation = false;
                ForceNewOrientation(settingOrientation);
            }
            else
            {
                // The real 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);
        }