private void DisplayAxisConfiguration(SerializedProperty axisConfig) { EditorGUILayout.PropertyField(axisConfig); if (!axisConfig.isExpanded) { return; } SerializedProperty name = axisConfig.FindPropertyRelative("name"); SerializedProperty description = axisConfig.FindPropertyRelative("description"); SerializedProperty positive = axisConfig.FindPropertyRelative("positive"); SerializedProperty altPositive = axisConfig.FindPropertyRelative("altPositive"); SerializedProperty negative = axisConfig.FindPropertyRelative("negative"); SerializedProperty altNegative = axisConfig.FindPropertyRelative("altNegative"); SerializedProperty deadZone = axisConfig.FindPropertyRelative("deadZone"); SerializedProperty gravity = axisConfig.FindPropertyRelative("gravity"); SerializedProperty sensitivity = axisConfig.FindPropertyRelative("sensitivity"); SerializedProperty snap = axisConfig.FindPropertyRelative("snap"); SerializedProperty invert = axisConfig.FindPropertyRelative("invert"); SerializedProperty type = axisConfig.FindPropertyRelative("type"); SerializedProperty axis = axisConfig.FindPropertyRelative("axis"); SerializedProperty joystick = axisConfig.FindPropertyRelative("joystick"); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(name); EditorGUILayout.PropertyField(description); // Positive Key EditorToolbox.KeyCodeField(ref _keyString, ref _editingPositiveKey, "Positive", "inspector_positive_key", PropertyToKeyCode(positive)); ProcessKeyString(ref _editingPositiveKey, positive); // Negative Key EditorToolbox.KeyCodeField(ref _keyString, ref _editingNegativeKey, "Negative", "inspector_negative_key", PropertyToKeyCode(negative)); ProcessKeyString(ref _editingNegativeKey, negative); // Alt Positive Key EditorToolbox.KeyCodeField(ref _keyString, ref _editingAltPositiveKey, "Alt Positive", "inspector_alt_positive_key", PropertyToKeyCode(altPositive)); ProcessKeyString(ref _editingAltPositiveKey, altPositive); // Alt Negative Key EditorToolbox.KeyCodeField(ref _keyString, ref _editingAltNegativeKey, "Alt Negative", "inspector_alt_negative_key", PropertyToKeyCode(altNegative)); ProcessKeyString(ref _editingAltNegativeKey, altNegative); EditorGUILayout.PropertyField(gravity, _gravityInfo); EditorGUILayout.PropertyField(deadZone, _deadZoneInfo); EditorGUILayout.PropertyField(sensitivity, _sensitivityInfo); EditorGUILayout.PropertyField(snap, _snapInfo); EditorGUILayout.PropertyField(invert); EditorGUILayout.PropertyField(type); axis.intValue = EditorGUILayout.Popup("Axis", axis.intValue, _axisOptions); joystick.intValue = EditorGUILayout.Popup("Joystick", joystick.intValue, _joystickOptions); EditorGUI.indentLevel--; }
private void DisplayAxisConfigurationFields(InputConfiguration inputConfigx, AxisConfiguration axisConfig, Rect screenRect) { GUIContent gravityInfo = new GUIContent("Gravity", "The speed(in units/sec) at which a digital axis falls towards neutral."); GUIContent sensitivityInfo = new GUIContent("Sensitivity", "The speed(in units/sec) at which an axis moves towards the target value."); GUIContent snapInfo = new GUIContent("Snap", "If input switches direction, do we snap to neutral and continue from there? For digital axes only."); GUIContent deadZoneInfo = new GUIContent("Dead Zone", "Size of analog dead zone. Values within this range map to neutral."); GUILayout.BeginArea(screenRect); _mainPanelScrollPos = GUILayout.BeginScrollView(_mainPanelScrollPos); axisConfig.name = EditorGUILayout.TextField("Name", axisConfig.name); axisConfig.description = EditorGUILayout.TextField("Description", axisConfig.description); // Positive Key EditorToolbox.KeyCodeField(ref _keyString, ref _editingPositiveKey, "Positive", "editor_positive_key", axisConfig.positive); ProcessKeyString(ref axisConfig.positive, ref _editingPositiveKey); // Negative Key EditorToolbox.KeyCodeField(ref _keyString, ref _editingNegativeKey, "Negative", "editor_negative_key", axisConfig.negative); ProcessKeyString(ref axisConfig.negative, ref _editingNegativeKey); // Alt Positive Key EditorToolbox.KeyCodeField(ref _keyString, ref _editingAltPositiveKey, "Alt Positive", "editor_alt_positive_key", axisConfig.altPositive); ProcessKeyString(ref axisConfig.altPositive, ref _editingAltPositiveKey); // Alt Negative key EditorToolbox.KeyCodeField(ref _keyString, ref _editingAltNegativeKey, "Alt Negative", "editor_alt_negative_key", axisConfig.altNegative); ProcessKeyString(ref axisConfig.altNegative, ref _editingAltNegativeKey); axisConfig.gravity = EditorGUILayout.FloatField(gravityInfo, axisConfig.gravity); axisConfig.deadZone = EditorGUILayout.FloatField(deadZoneInfo, axisConfig.deadZone); axisConfig.sensitivity = EditorGUILayout.FloatField(sensitivityInfo, axisConfig.sensitivity); axisConfig.snap = EditorGUILayout.Toggle(snapInfo, axisConfig.snap); axisConfig.invert = EditorGUILayout.Toggle("Invert", axisConfig.invert); axisConfig.type = (InputType)EditorGUILayout.EnumPopup("Type", axisConfig.type); axisConfig.axis = EditorGUILayout.Popup("Axis", axisConfig.axis, _axisOptions); axisConfig.joystick = EditorGUILayout.Popup("Joystick", axisConfig.joystick, _joystickOptions); if (EditorApplication.isPlaying) { EditorGUILayout.Space(); GUI.enabled = false; EditorGUILayout.FloatField("Raw Axis", axisConfig.GetAxisRaw()); EditorGUILayout.FloatField("Axis", axisConfig.GetAxis()); EditorGUILayout.Toggle("Button", axisConfig.GetButton()); GUI.enabled = true; } GUILayout.EndScrollView(); GUILayout.EndArea(); }