public SimulatorControlPanel(VisualElement rootElement, DeviceInfo deviceInfo, SystemInfoSimulation systemInfoSimulation, ScreenSimulation screenSimulation,
                                     ApplicationSimulation applicationSimulation,
                                     SimulationPlayerSettings playerSettings, SimulatorSerializationStates states)
        {
            m_RootElement = rootElement;

            m_DeviceSpecifications         = new SimulatorDeviceSpecificationsUI(m_RootElement.Q <Foldout>("device-specifications"), deviceInfo, systemInfoSimulation);
            m_SimulatorScreenSettings      = new SimulatorScreenSettingsUI(m_RootElement.Q <Foldout>("screen-settings"), deviceInfo, screenSimulation, playerSettings);
            m_SimulatorApplicationSettings = new SimulatorApplicationSettingsUI(m_RootElement.Q <Foldout>("application-settings"), applicationSimulation, states);
            m_SimulatorExtensions          = new SimulatorExtensions();

            foreach (var extension in m_SimulatorExtensions.Extensions)
            {
                var foldout = new Foldout()
                {
                    text  = extension.extensionTitle,
                    value = false
                };
                foldout.AddToClassList("unity-device-simulator__control-panel_foldout");

                m_RootElement.Add(foldout);
                m_ExtensionFoldouts.Add(extension.GetType().ToString(), foldout);

                if (states != null && states.extensions.TryGetValue(extension.GetType().ToString(), out var serializedExtension))
                {
                    JsonUtility.FromJsonOverwrite(serializedExtension, extension);
                }

                extension.OnExtendDeviceSimulator(foldout);
            }
        }
        // TODO get rid of this method when we deprecate DeserializeView, currently exists as a hack
        public void ApplySerializationStates(SimulatorSerializationStates states)
        {
            if (states == null)
            {
                return;
            }

            bool state;

            if (states.controlPanelFoldouts.TryGetValue(m_DeviceSpecifications.GetType().ToString(), out state))
            {
                m_DeviceSpecifications.m_RootElement.value = state;
            }
            if (states.controlPanelFoldouts.TryGetValue(m_SimulatorScreenSettings.GetType().ToString(), out state))
            {
                m_SimulatorScreenSettings.m_RootElement.value = state;
            }
            if (states.controlPanelFoldouts.TryGetValue(m_SimulatorApplicationSettings.GetType().ToString(), out state))
            {
                m_SimulatorApplicationSettings.m_RootElement.value = state;
            }

            foreach (var foldout in m_ExtensionFoldouts)
            {
                if (states.controlPanelFoldouts.TryGetValue(foldout.Key, out state))
                {
                    foldout.Value.value = state;
                }
            }
        }
        public void ApplySerializationStates(SimulatorSerializationStates states)
        {
            if (states == null)
            {
                return;
            }

            m_LeftPanelHidden = states.controlPanelHidden;
            m_LeftPaneWidth   = states.controlPanelWidth;
        }
        public void StoreSerializationStates(ref SimulatorSerializationStates states)
        {
            states.controlPanelFoldouts.Add(m_DeviceSpecifications.GetType().ToString(), m_DeviceSpecifications.m_RootElement.value);
            states.controlPanelFoldouts.Add(m_SimulatorScreenSettings.GetType().ToString(), m_SimulatorScreenSettings.m_RootElement.value);
            states.controlPanelFoldouts.Add(m_SimulatorApplicationSettings.GetType().ToString(), m_SimulatorApplicationSettings.m_RootElement.value);

            foreach (var foldout in m_ExtensionFoldouts)
            {
                states.controlPanelFoldouts.Add(foldout.Key, foldout.Value.value);
            }

            foreach (var extension in m_SimulatorExtensions.Extensions)
            {
                var serializedExtension = JsonUtility.ToJson(extension);
                states.extensions.Add(extension.GetType().ToString(), serializedExtension);
            }
        }
 public void StoreSerializationStates(ref SimulatorSerializationStates states)
 {
     states.controlPanelHidden = m_LeftPanelHidden;
     states.controlPanelWidth  = m_LeftPanelHidden ? m_PreviousLeftPaneWidth : m_LeftPaneWidth;
 }
Exemple #6
0
 public void StoreSerializationStates(ref SimulatorSerializationStates states)
 {
     states.systemLanguage      = (SystemLanguage)m_SystemLanguageEnumField.value;
     states.networkReachability = (NetworkReachability)m_InternetReachabilityEnumField.value;
 }
Exemple #7
0
        public SimulatorApplicationSettingsUI(Foldout rootElement, ApplicationSimulation applicationSimulation, SimulatorSerializationStates states)
        {
            m_RootElement           = rootElement;
            m_ApplicationSimulation = applicationSimulation;

            m_SystemLanguageEnumField = m_RootElement.Q <EnumField>("application-system-language");
            m_SystemLanguageEnumField.Init(states?.systemLanguage ?? SystemLanguage.English);
            m_ApplicationSimulation.ShimmedSystemLanguage = (SystemLanguage)m_SystemLanguageEnumField.value;
            m_SystemLanguageEnumField.RegisterValueChangedCallback((evt) => { m_ApplicationSimulation.ShimmedSystemLanguage = (SystemLanguage)evt.newValue; });

            m_InternetReachabilityEnumField = m_RootElement.Q <EnumField>("application-internet-reachability");
            m_InternetReachabilityEnumField.Init(states?.networkReachability ?? NetworkReachability.NotReachable);
            m_ApplicationSimulation.ShimmedInternetReachability = (NetworkReachability)m_InternetReachabilityEnumField.value;
            m_InternetReachabilityEnumField.RegisterValueChangedCallback((evt) => { m_ApplicationSimulation.ShimmedInternetReachability = (NetworkReachability)evt.newValue; });

            var onLowMemoryButton = m_RootElement.Q <Button>("application-low-memory");

            onLowMemoryButton.clickable = new Clickable(() => m_ApplicationSimulation.OnLowMemory());
        }