diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index b0d94475a1..677b997df6 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed ### Added - +- Added TwoAxisVector2Composite ## [1.19.0] - 2026-02-24 diff --git a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/TwoAxisVector2Composite.cs b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/TwoAxisVector2Composite.cs new file mode 100644 index 0000000000..f3189c2483 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/TwoAxisVector2Composite.cs @@ -0,0 +1,46 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using UnityEngine.InputSystem; +using UnityEngine.InputSystem.Layouts; +using UnityEngine.InputSystem.Utilities; + + +#endif + +namespace UnityEngine.InputSystem.Composites +{ + /// + /// A Vector2 composite consisting of two Axis values. + /// + /// + /// This composite allows for two Axis inputs to be combined into a Vector2 representation. + /// + /// This is particularly useful for legacy Joysticks without Gamepad-promised Vector2 representations. + /// + [DisplayStringFormat("{xAxis}+{yAxis}")] + public class TwoAxisVector2Composite : InputBindingComposite + { + [InputControl(layout = "Axis")] + public int xAxis; + + [InputControl(layout = "Axis")] + public int yAxis; + + public override Vector2 ReadValue(ref InputBindingCompositeContext context) + { + var firstPartValue = context.ReadValue(xAxis); + var secondPartValue = context.ReadValue(yAxis); + + return new(firstPartValue, secondPartValue); + } + + static TwoAxisVector2Composite() + { + InputSystem.RegisterBindingComposite(); + } + + [RuntimeInitializeOnLoadMethod] + static void Init() { } // Trigger static constructor. + } +} \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/TwoAxisVector2Composite.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/TwoAxisVector2Composite.cs.meta new file mode 100644 index 0000000000..e65379f2fb --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/TwoAxisVector2Composite.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 42bb5bf482de61a478150f4d825a9120 \ No newline at end of file