Exemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            GUILayout.Space(10);
            if (GUILayout.Button("Open Input Settings Window", GUILayout.Height(30)))
            {
                InputSettingsProvider.Open();
            }
            GUILayout.Space(10);

            if (InputSystem.settings == target)
            {
                EditorGUILayout.HelpBox("This asset contains the currently active settings for the Input System.", MessageType.Info);
            }
            else
            {
                string currentlyActiveAssetsPath = null;
                if (InputSystem.settings != null)
                {
                    currentlyActiveAssetsPath = AssetDatabase.GetAssetPath(InputSystem.settings);
                }
                if (!string.IsNullOrEmpty(currentlyActiveAssetsPath))
                {
                    currentlyActiveAssetsPath = $"The currently active settings are stored in {currentlyActiveAssetsPath}. ";
                }
                EditorGUILayout.HelpBox($"Note that this asset does not contain the currently active settings for the Input System. {currentlyActiveAssetsPath??""}Click \"Make Active\" below to make {target.name} the active one.", MessageType.Warning);
                if (GUILayout.Button($"Make active", EditorStyles.miniButton))
                {
                    InputSystem.settings = (InputSettings)target;
                }
            }
        }
Exemplo n.º 2
0
            public void OnGUI()
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUI.BeginDisabledGroup(m_UseDefaultValue);
                var value = m_GetValue();

                if (m_UseDefaultValue)
                {
                    value = m_GetDefaultValue();
                }
                ////TODO: use slider rather than float field
                var newValue = EditorGUILayout.FloatField(m_ValueLabel, value, GUILayout.ExpandWidth(false));

                if (!m_UseDefaultValue)
                {
                    m_SetValue(newValue);
                }
                EditorGUI.EndDisabledGroup();
                var newUseDefault = GUILayout.Toggle(m_UseDefaultValue, m_ToggleLabel, GUILayout.ExpandWidth(false));

                if (newUseDefault != m_UseDefaultValue)
                {
                    if (!newUseDefault)
                    {
                        m_SetValue(m_GetDefaultValue());
                    }
                    else
                    {
                        m_SetValue(m_DefaultInitializedValue);
                    }
                }
                m_UseDefaultValue = newUseDefault;
                EditorGUILayout.EndHorizontal();

                // If we're using a default from global InputSettings, show info text for that and provide
                // button to open input settings.
                if (m_UseDefaultValue && m_DefaultComesFromInputSettings)
                {
                    EditorGUILayout.HelpBox(m_HelpBoxText);
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button(m_OpenInputSettingsLabel, EditorStyles.miniButton))
                    {
                        InputSettingsProvider.Open();
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
Exemplo n.º 3
0
        private void DoUtilityButtonsUI()
        {
            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button(m_OpenSettingsText, EditorStyles.miniButton))
            {
                InputSettingsProvider.Open();
            }

            if (GUILayout.Button(m_OpenDebuggerText, EditorStyles.miniButton))
            {
                InputDebuggerWindow.CreateOrShow();
            }

            EditorGUILayout.EndHorizontal();
        }
            public void OnGUI()
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUI.BeginDisabledGroup(m_UseDefaultValue);

                var value = m_GetValue();

                if (m_UseDefaultValue)
                {
                    value = m_GetDefaultValue();
                }

                // If previous value was an epsilon away from default value, it most likely means that value was set by our own code down in this method.
                // Revert it back to default to show a nice readable value in UI.
                // ReSharper disable once CompareOfFloatsByEqualityOperator
                if ((value - float.Epsilon) == m_DefaultInitializedValue)
                {
                    value = m_DefaultInitializedValue;
                }

                ////TODO: use slider rather than float field
                var newValue = EditorGUILayout.FloatField(m_ValueLabel, value, GUILayout.ExpandWidth(false));

                if (!m_UseDefaultValue)
                {
                    // ReSharper disable once CompareOfFloatsByEqualityOperator
                    if (newValue == m_DefaultInitializedValue)
                    {
                        // If user sets a value that is equal to default initialized, change value slightly so it doesn't pass potential default checks.
                        ////TODO: refactor all of this to use tri-state values instead, there is no obvious float value that we can use as default (well maybe NaN),
                        ////so instead it would be better to have a separate bool to show if value is present or not.
                        m_SetValue(newValue + float.Epsilon);
                    }
                    else
                    {
                        m_SetValue(newValue);
                    }
                }

                EditorGUI.EndDisabledGroup();

                var newUseDefault = GUILayout.Toggle(m_UseDefaultValue, m_ToggleLabel, GUILayout.ExpandWidth(false));

                if (newUseDefault != m_UseDefaultValue)
                {
                    if (!newUseDefault)
                    {
                        m_SetValue(m_GetDefaultValue());
                    }
                    else
                    {
                        m_SetValue(m_DefaultInitializedValue);
                    }
                }

                m_UseDefaultValue = newUseDefault;
                EditorGUILayout.EndHorizontal();

                // If we're using a default from global InputSettings, show info text for that and provide
                // button to open input settings.
                if (m_UseDefaultValue && m_DefaultComesFromInputSettings)
                {
                    EditorGUILayout.HelpBox(m_HelpBoxText);
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button(m_OpenInputSettingsLabel, EditorStyles.miniButton))
                    {
                        InputSettingsProvider.Open();
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }