コード例 #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;
                }
            }
        }
コード例 #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 = EditorGUILayout.ToggleLeft(m_ToggleLabel, m_UseDefaultValue, GUILayout.ExpandWidth(false));

                if (newUseDefault != m_UseDefaultValue)
                {
                    if (!newUseDefault)
                    {
                        m_SetValue(m_GetDefaultValue());
                    }
                    else
                    {
                        m_SetValue(0);
                    }
                }
                m_UseDefaultValue = newUseDefault;
                EditorGUILayout.EndHorizontal();
                if (m_UseDefaultValue)
                {
                    EditorGUILayout.HelpBox(m_HelpBoxText);
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button(m_OpenInputSettingsLabel, EditorStyles.miniButton, GUILayout.MaxWidth(100)))
                    {
                        InputSettingsProvider.Open();
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }