Skip to content

Commit 5d4e82f

Browse files
jamesmcgillchris-at-unityRogPodge
authored
CHANGE: Replaced XR layout builder logic to create Axis2D inputs as Stick controls (#1649)
* [CHANGE] Replaced XR layout builder logic to create Axis2D inputs as Stick controls * Moved cahngelog entry to unreleased list. * Updated XRTests with proper layout * Fixed broken RotateToFrom implementation * Moved changelog entry to Unreleased section --------- Co-authored-by: Chris Rodríguez <chris.rodriguez@unity3d.com> Co-authored-by: chris-at-unity <124618947+chris-at-unity@users.noreply.github.com> Co-authored-by: roger.liu <roger.liu@unity3d.com> Co-authored-by: RogPodge <39840334+RogPodge@users.noreply.github.com>
1 parent 7e6a029 commit 5d4e82f

4 files changed

Lines changed: 7 additions & 4 deletions

File tree

Assets/Tests/InputSystem/Plugins/UITests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ public Quaternion RotateFromTo(Vector3 position, GameObject from, GameObject to)
108108
{
109109
var fromPosition = from.GetComponent<RectTransform>().position;
110110
var toPosition = to.GetComponent<RectTransform>().position;
111-
var angle = Mathf.Asin((fromPosition - toPosition).magnitude / (position - fromPosition).magnitude);
112-
return Quaternion.Euler(0, angle * Mathf.Rad2Deg, 0);
111+
var angle = Vector3.Angle(fromPosition - position, toPosition - position);
112+
return Quaternion.Euler(0, angle, 0);
113113
}
114114
}
115115

Assets/Tests/InputSystem/Plugins/XRTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public void Layouts_AllFeatureTypes_AreRepresentedInTheGeneratedLayout()
255255
var vec2Control = generatedLayout["Vector2"];
256256
Assert.That(vec2Control.name, Is.EqualTo(new InternedString("Vector2")));
257257
Assert.That(vec2Control.offset, Is.EqualTo(12));
258-
Assert.That(vec2Control.layout, Is.EqualTo(new InternedString("Vector2")));
258+
Assert.That(vec2Control.layout, Is.EqualTo(new InternedString("Stick")));
259259
Assert.That(vec2Control.usages.Count, Is.EqualTo(1));
260260
Assert.That(vec2Control.usages[0], Is.EqualTo(new InternedString("Axis2DUsage")));
261261

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ however, it has to be formatted properly to pass verification tests.
1515
- Added `InputSystem.runInBackground` to be used internally by specific platforms packages. Allows telling the input system that a specific platform runs in background. It allows fixing of [case UUM-6744](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-6744).
1616
- Added new UIToolkit version of the `InputActionsAsset` editor. Currently this is incomplete (view-only) and the existing editor is still used by default.
1717

18+
### Changed
19+
- Changed XR Layout build behavior to create Axis2D control devices with `StickControl` type instead of `Vector2Control`.
20+
1821
## [1.5.1] - 2023-03-15
1922

2023
### Fixed

Packages/com.unity.inputsystem/InputSystem/Plugins/XR/XRLayoutBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ private InputControlLayout Build()
282282
case FeatureType.Axis2D:
283283
{
284284
builder.AddControl(featureName)
285-
.WithLayout("Vector2")
285+
.WithLayout("Stick")
286286
.WithByteOffset(currentOffset)
287287
.WithFormat(InputStateBlock.FormatVector2)
288288
.WithUsages(currentUsages);

0 commit comments

Comments
 (0)