Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// A Vector2 composite consisting of two Axis values.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
[DisplayStringFormat("{xAxis}+{yAxis}")]
public class TwoAxisVector2Composite : InputBindingComposite<Vector2>
{
[InputControl(layout = "Axis")]
public int xAxis;

[InputControl(layout = "Axis")]
public int yAxis;

public override Vector2 ReadValue(ref InputBindingCompositeContext context)
{
var firstPartValue = context.ReadValue<float>(xAxis);
var secondPartValue = context.ReadValue<float>(yAxis);

return new(firstPartValue, secondPartValue);
}

static TwoAxisVector2Composite()
{
InputSystem.RegisterBindingComposite<TwoAxisVector2Composite>();
}

[RuntimeInitializeOnLoadMethod]
static void Init() { } // Trigger static constructor.
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.