private void InitPlayerSettings(SimulatorJsonSerialization states) { // Initialize customized player settings. if (states != null) { m_CustomizedPlayerSettings = states.customizedPlayerSettings; } else { m_CustomizedPlayerSettings = new SimulationPlayerSettings() { targetDpi = (int)m_DeviceInfo.Screens[0].dpi }; } }
private void Init(SimulatorJsonSerialization states) { if (states != null) { m_Scale = states.scale; m_FitToScreenEnabled = states.fitToScreenEnabled; m_RotationDegree = states.rotationDegree; m_Rotation = states.rotation; m_HighlightSafeArea = states.highlightSafeAreaEnabled; } InitPreviewToolbar(); InitInactiveMsg(); InitPreview(); ComputeBoundingBox(); }
public SimulatorPreviewPanel(VisualElement rootElement, InputProvider inputProvider, DeviceInfo deviceInfo, SimulatorJsonSerialization states) { m_RootElement = rootElement; m_InputProvider = inputProvider; m_DeviceInfo = deviceInfo; EditorApplication.playModeStateChanged += OnEditorPlayModeStateChanged; Init(states); }
public SimulatorPreviewPanel(VisualElement rootElement, InputProvider inputProvider, DeviceInfo deviceInfo, SimulatorJsonSerialization states) { m_RootElement = rootElement; m_InputProvider = inputProvider; m_DeviceInfo = deviceInfo; var userSettings = DeviceSimulatorUserSettingsProvider.LoadOrCreateSettings(); m_HighlightSafeAreaColor = userSettings.SafeAreaHighlightColor; m_HighlightSafeAreaLineWidth = userSettings.SafeAreaHighlightLineWidth; Init(states); }
private void Init(SimulatorJsonSerialization states) { InitPlayerSettings(states); bool overrideDefaultPlayerSettings = (states != null) ? states.overrideDefaultPlayerSettings : false; m_OverrideDefaultPlayerSettings = m_RootElement.Q <Toggle>("override-default-player-settings"); m_OverrideDefaultPlayerSettings.RegisterValueChangedCallback(SetOverridePlayerSettings); m_OverrideDefaultPlayerSettings.SetValueWithoutNotify(overrideDefaultPlayerSettings); UpdateOverridePlayerSettingsStatus(); m_CustomizedPlayerSettingsElement = m_RootElement.Q <VisualElement>("customized-player-settings"); m_StartInFullscreen = m_RootElement.Q <Toggle>("android-start-in-fullscreen"); m_StartInFullscreen.SetValueWithoutNotify(m_CustomizedPlayerSettings.androidStartInFullscreen); m_StartInFullscreen.RegisterValueChangedCallback((evt) => { m_CustomizedPlayerSettings.androidStartInFullscreen = evt.newValue; }); m_ResolutionScalingMode = m_RootElement.Q <EnumField>("resolution-scaling-mode"); m_ResolutionScalingMode.Init(ResolutionScalingMode.Disabled); m_ResolutionScalingMode.RegisterValueChangedCallback(SetResolutionScalingMode); m_ResolutionScalingMode.SetValueWithoutNotify(m_CustomizedPlayerSettings.resolutionScalingMode); #region DPI m_DpiContainer = m_RootElement.Q <VisualElement>("dpi-container"); m_DpiSlider = m_DpiContainer.Q <SliderInt>("dpi-slider"); m_DpiSlider.RegisterValueChangedCallback(SyncDpiField); m_DpiSlider.SetValueWithoutNotify(m_CustomizedPlayerSettings.targetDpi); m_DpiField = m_DpiContainer.Q <IntegerField>("dpi-field"); m_DpiField.RegisterValueChangedCallback(SyncDpiSlider); m_DpiField.RegisterCallback <KeyDownEvent>(OnDpiFieldKeyDown); m_DpiField.SetValueWithoutNotify(m_CustomizedPlayerSettings.targetDpi); #endregion #region Orientation m_DefaultOrientation = m_RootElement.Q <EnumField>("default-screen-orientation"); m_DefaultOrientation.Init(UIOrientation.AutoRotation); m_DefaultOrientation.RegisterValueChangedCallback(SetDefaultOrientation); m_DefaultOrientation.SetValueWithoutNotify(m_CustomizedPlayerSettings.defaultOrientation); m_AllowedOrienations = m_RootElement.Q <Foldout>("allowed-orientations"); m_AllowedPortrait = m_AllowedOrienations.Q <Toggle>("orientation-allow-portrait"); m_AllowedPortrait.SetValueWithoutNotify(m_CustomizedPlayerSettings.allowedPortrait); m_AllowedPortrait.RegisterValueChangedCallback((evt) => { m_CustomizedPlayerSettings.allowedPortrait = evt.newValue; }); m_AllowedPortraitUpsideDown = m_AllowedOrienations.Q <Toggle>("orientation-allow-portrait-upside-down"); m_AllowedPortraitUpsideDown.SetValueWithoutNotify(m_CustomizedPlayerSettings.allowedPortraitUpsideDown); m_AllowedPortraitUpsideDown.RegisterValueChangedCallback((evt) => { m_CustomizedPlayerSettings.allowedPortraitUpsideDown = evt.newValue; }); m_AllowedLandscapeLeft = m_AllowedOrienations.Q <Toggle>("orientation-allow-landscape-left"); m_AllowedLandscapeLeft.SetValueWithoutNotify(m_CustomizedPlayerSettings.allowedLandscapeLeft); m_AllowedLandscapeLeft.RegisterValueChangedCallback((evt) => { m_CustomizedPlayerSettings.allowedLandscapeLeft = evt.newValue; }); m_AllowedLandscapeRight = m_AllowedOrienations.Q <Toggle>("orientation-allow-landscape-right"); m_AllowedLandscapeRight.SetValueWithoutNotify(m_CustomizedPlayerSettings.allowedLandscapeRight); m_AllowedLandscapeRight.RegisterValueChangedCallback((evt) => { m_CustomizedPlayerSettings.allowedLandscapeRight = evt.newValue; }); #endregion #region Graphics API m_AutoGraphicsAPI = m_RootElement.Q <Toggle>("auto-graphics-api"); m_AutoGraphicsAPI.SetValueWithoutNotify(m_CustomizedPlayerSettings.autoGraphicsAPI); m_AutoGraphicsAPI.RegisterValueChangedCallback(SetAutoGraphicsAPI); m_GraphicsAPIPlaceholder = m_RootElement.Q <VisualElement>("graphics-api-placeholder"); m_GraphicsAPIPlaceholder.SetEnabled(!m_CustomizedPlayerSettings.autoGraphicsAPI); #endregion UpdateCustomizedPlayerSettings(m_OverrideDefaultPlayerSettings.value); UpdateStartInFullScreen(); UpdateResolutionScalingMode(m_CustomizedPlayerSettings.resolutionScalingMode); UpdateAllowedOrientations(m_CustomizedPlayerSettings.defaultOrientation); UpdateGraphicsAPI(); }
public SimulatorPlayerSettingsUI(VisualElement rootElement, DeviceInfo deviceInfo, SimulatorJsonSerialization states) { m_RootElement = rootElement; m_DeviceInfo = deviceInfo; Init(states); }