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 void Enable() { ShimManager.UseShim(this); }
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); }