Skip to content

Commit

Permalink
Merge branch 'develop' into docs-quality-week-2024-uiinputmodule
Browse files Browse the repository at this point in the history
  • Loading branch information
jfreire-unity authored Dec 10, 2024
2 parents 9410bb6 + eca97b8 commit c977d73
Show file tree
Hide file tree
Showing 21 changed files with 533 additions and 225 deletions.
5 changes: 5 additions & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ however, it has to be formatted properly to pass verification tests.
- Fixed tooltip support in the UI Toolkit version of the Input Actions Asset editor.
- Fixed documentation to clarify bindings with modifiers `overrideModifiersNeedToBePressedFirst` configuration [ISXB-806](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-806).
- Fixed an issue in `Samples/Visualizers/GamepadVisualizer.unity` sample where the visualization wouldn't handle device disconnects or current device changes properly (ISXB-1243).
- Fixed an issue when displaying Serialized InputAction's Processor properties inside the Inspector window. [ISXB-1269](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1269)
- Fixed an issue with default device selection when adding new Control Scheme.

### Changed
- Added back the InputManager to InputSystem project-wide asset migration code with performance improvement (ISX-2086).
- Changed `OnScreenControl` to automaticaly switch, in Single Player with autoswitch enabled, to the target device control scheme when the first component is enabled to prevent bad interactions when it start.
- Changed paremeter `overrideModifiersNeedToBePressedFirst` to obsolete for `ButtonWithOneModifier`, `ButtonWithTwoModifiers`, `OneModifierComposite` and `TwoModifiersComposite` in favour the new `modifiersOrder` parameter which is more explicit.
- Changed `Samples/Visualizers/GamepadVisualizer.unity` to visualize the control values of the current device instead of the first device.

### Added
- Added new API `InputSystem.settings.useIMGUIEditorForAssets` that should be used in custom `InputParameterEditor` that use both IMGUI and UI Toolkit.

## [1.11.2] - 2024-10-16

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ internal class AxisCompositeEditor : InputParameterEditor<AxisComposite>
public override void OnGUI()
{
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
if (!InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)) return;
if (!InputSystem.settings.useIMGUIEditorForAssets) return;
#endif
target.whichSideWins = (AxisComposite.WhichSideWins)EditorGUILayout.EnumPopup(m_WhichAxisWinsLabel, target.whichSideWins);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ internal class Vector2CompositeEditor : InputParameterEditor<Vector2Composite>
public override void OnGUI()
{
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
if (!InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)) return;
if (!InputSystem.settings.useIMGUIEditorForAssets) return;
#endif
target.mode = (Vector2Composite.Mode)EditorGUILayout.EnumPopup(m_ModeLabel, target.mode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ internal class Vector3CompositeEditor : InputParameterEditor<Vector3Composite>
public override void OnGUI()
{
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
if (!InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)) return;
if (!InputSystem.settings.useIMGUIEditorForAssets) return;
#endif
target.mode = (Vector3Composite.Mode)EditorGUILayout.EnumPopup(m_ModeLabel, target.mode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected override void OnEnable()
public override void OnGUI()
{
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
if (!InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)) return;
if (!InputSystem.settings.useIMGUIEditorForAssets) return;
#endif
m_PressPointSetting.OnGUI();
m_DurationSetting.OnGUI();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ protected override void OnEnable()
public override void OnGUI()
{
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
if (!InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)) return;
if (!InputSystem.settings.useIMGUIEditorForAssets) return;
#endif
target.tapCount = EditorGUILayout.IntField(m_TapCountLabel, target.tapCount);
m_TapDelaySetting.OnGUI();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ protected override void OnEnable()
public override void OnGUI()
{
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
if (!InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)) return;
if (!InputSystem.settings.useIMGUIEditorForAssets) return;
#endif
EditorGUILayout.HelpBox(s_HelpBoxText);
target.behavior = (PressBehavior)EditorGUILayout.EnumPopup(s_PressBehaviorLabel, target.behavior);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected override void OnEnable()
public override void OnGUI()
{
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
if (!InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)) return;
if (!InputSystem.settings.useIMGUIEditorForAssets) return;
#endif
m_DurationSetting.OnGUI();
m_PressPointSetting.OnGUI();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected override void OnEnable()
public override void OnGUI()
{
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
if (!InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)) return;
if (!InputSystem.settings.useIMGUIEditorForAssets) return;
#endif
m_DurationSetting.OnGUI();
m_PressPointSetting.OnGUI();
Expand Down
78 changes: 64 additions & 14 deletions Packages/com.unity.inputsystem/InputSystem/Controls/InputControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace UnityEngine.InputSystem
/// which has APIs specific to the type of value of the control (e.g. <see cref="InputControl{TValue}.ReadValue()"/>.
///
/// The following example demonstrates various common operations performed on input controls:
///
/// </remarks>
/// <example>
/// <code>
/// // Look up dpad/up control on current gamepad.
Expand All @@ -99,10 +99,7 @@ namespace UnityEngine.InputSystem
/// leftStickHistory.Enable();
/// </code>
/// </example>
/// <example>
/// </example>
/// </remarks>
/// <see cref="InputControl{TValue}"/>
/// <seealso cref="InputControl{TValue}"/>
/// <seealso cref="InputDevice"/>
/// <seealso cref="InputControlPath"/>
/// <seealso cref="InputStateBlock"/>
Expand Down Expand Up @@ -611,6 +608,8 @@ public virtual unsafe void WriteValueFromObjectIntoState(object value, void* sta
/// Note that if the given path matches multiple child controls, only the first control
/// encountered in the search will be returned.
///
/// This method is equivalent to calling <see cref="InputControlPath.TryFindChild"/>.
/// </remarks>
/// <example>
/// <code>
/// // Returns the leftStick control of the current gamepad.
Expand All @@ -625,9 +624,6 @@ public virtual unsafe void WriteValueFromObjectIntoState(object value, void* sta
/// Gamepad.current.TryGetChildControl("*stick");
/// </code>
/// </example>
///
/// This method is equivalent to calling <see cref="InputControlPath.TryFindChild"/>.
/// </remarks>
public InputControl TryGetChildControl(string path)
{
if (string.IsNullOrEmpty(path))
Expand Down Expand Up @@ -689,7 +685,7 @@ protected InputControl()
/// <remarks>
/// This method can be overridden to perform control- or device-specific setup work. The most
/// common use case is for looking up child controls and storing them in local getters.
///
/// </remarks>
/// <example>
/// <code>
/// public class MyDevice : InputDevice
Expand All @@ -706,7 +702,6 @@ protected InputControl()
/// }
/// </code>
/// </example>
/// </remarks>
protected virtual void FinishSetup()
{
}
Expand All @@ -723,9 +718,12 @@ protected virtual void FinishSetup()
///
/// This method should be called if you are accessing cached data set up by
/// <see cref="RefreshConfiguration"/>.
///
/// </remarks>
/// <example>
/// <code>
/// using UnityEngine.InputSystem;
/// using UnityEngine.InputSystem.Utilities;
///
/// // Let's say your device has an associated orientation which it can be held with
/// // and you want to surface both as a property and as a usage on the device.
/// // Whenever your backend code detects a change in orientation, it should send
Expand Down Expand Up @@ -779,7 +777,6 @@ protected virtual void FinishSetup()
/// }
/// </code>
/// </example>
/// </remarks>
/// <seealso cref="RefreshConfiguration"/>
protected void RefreshConfigurationIfNeeded()
{
Expand All @@ -790,6 +787,61 @@ protected void RefreshConfigurationIfNeeded()
}
}

/// <summary>
/// Refresh the configuration of the control. This is used to update the control's state (e.g. Keyboard Layout or display Name of Keys).
/// </summary>
/// <remarks>
/// The system will call this method automatically whenever a change is made to one of the control's configuration properties.
/// See <see cref="RefreshConfigurationIfNeeded"/>.
/// </remarks>
/// <example>
/// <code>
/// using UnityEngine.InputSystem;
/// using UnityEngine.InputSystem.Utilities;
///
/// public class MyDevice : InputDevice
/// {
/// public enum Orientation
/// {
/// Horizontal,
/// Vertical,
/// }
/// private Orientation m_Orientation;
/// private static InternedString s_Vertical = new InternedString("Vertical");
/// private static InternedString s_Horizontal = new InternedString("Horizontal");
///
/// public Orientation orientation
/// {
/// get
/// {
/// // Call RefreshOrientation if the configuration of the device has been
/// // invalidated since last time we initialized m_Orientation.
/// // Calling RefreshConfigurationIfNeeded() is sufficient in most cases, RefreshConfiguration() forces the refresh.
/// RefreshConfiguration();
/// return m_Orientation;
/// }
/// }
/// protected override void RefreshConfiguration()
/// {
/// // Set Orientation back to horizontal. Alternatively fetch from device.
/// m_Orientation = Orientation.Horizontal;
/// // Reflect the orientation on the device.
/// switch (m_Orientation)
/// {
/// case Orientation.Vertical:
/// InputSystem.RemoveDeviceUsage(this, s_Horizontal);
/// InputSystem.AddDeviceUsage(this, s_Vertical);
/// break;
///
/// case Orientation.Horizontal:
/// InputSystem.RemoveDeviceUsage(this, s_Vertical);
/// InputSystem.AddDeviceUsage(this, s_Horizontal);
/// break;
/// }
/// }
/// }
/// </code>
/// </example>
protected virtual void RefreshConfiguration()
{
}
Expand Down Expand Up @@ -902,8 +954,6 @@ protected virtual FourCC CalculateOptimizedControlDataType()
/// <summary>
/// Apply built-in parameters changes (e.g. <see cref="AxisControl.invert"/>, others), recompute <see cref="InputControl.optimizedControlDataType"/> for impacted controls and clear cached value.
/// </summary>
/// <remarks>
/// </remarks>
public void ApplyParameterChanges()
{
// First we go through all children of our own hierarchy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public int scanCode
return m_ScanCode;
}
}

/// <inheritdoc/>
protected override void RefreshConfiguration()
{
// Wipe our last cached set of data (if any).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected override void OnEnable()
public override void OnGUI()
{
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
if (!InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)) return;
if (!InputSystem.settings.useIMGUIEditorForAssets) return;
#endif
m_MinSetting.OnGUI();
m_MaxSetting.OnGUI();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected override void OnEnable()
public override void OnGUI()
{
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
if (!InputSystem.settings.IsFeatureEnabled(InputFeatureNames.kUseIMGUIEditorForAssets)) return;
if (!InputSystem.settings.useIMGUIEditorForAssets) return;
#endif
m_MinSetting.OnGUI();
m_MaxSetting.OnGUI();
Expand Down
Loading

0 comments on commit c977d73

Please sign in to comment.