Skip to content

Commit d5cbbce

Browse files
authored
CHANGE: TrackedPoseDriver now uses InputActionProperty instead of direct InputActions (Unity-Technologies#1234).
1 parent 13299cf commit d5cbbce

File tree

7 files changed

+308
-62
lines changed

7 files changed

+308
-62
lines changed

Assets/Tests/InputSystem/APIVerificationTests.cs

+4
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,10 @@ public InputEventBuffer(Unity.Collections.NativeArray<byte> buffer, int eventCou
778778
public void AppendEvent(UnityEngine.InputSystem.LowLevel.InputEvent* eventPtr, int capacityIncrementInBytes = 2048);
779779
public UnityEngine.InputSystem.LowLevel.InputEvent* AllocateEvent(int sizeInBytes, int capacityIncrementInBytes = 2048);
780780
")]
781+
// TrackedPose Driver changes
782+
[Property("Exclusions", @"1.0.0
783+
public class TrackedPoseDriver : UnityEngine.MonoBehaviour
784+
")]
781785
[ScopedExclusionProperty("1.0.0", "UnityEngine.InputSystem.Editor", "public sealed class InputControlPathEditor : System.IDisposable", "public void OnGUI(UnityEngine.Rect rect);")]
782786
public void API_MinorVersionsHaveNoBreakingChanges()
783787
{

Assets/Tests/InputSystem/Plugins/XRTests.cs

+68-3
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public void Layouts_XRGeneratedLayoutNames_OnlyContainAllowedCharacters()
117117
Assert.That(InputSystem.devices, Has.Count.EqualTo(1));
118118
var createdDevice = InputSystem.devices[0];
119119

120-
Assert.AreEqual(createdDevice.layout, "XRInputV1::Manufacturer::XRThisLayoutShouldhave1ValidName");
120+
Assert.AreEqual(createdDevice.layout, "XRInputV1::__Manufacturer::XR_ThisLayoutShouldhave1ValidName");
121121
}
122122

123123
[Test]
@@ -361,8 +361,8 @@ public void Components_CanUpdateGameObjectTransformThroughTrackedPoseDriver()
361361
var rotationAction = new InputAction();
362362
rotationAction.AddBinding("<TestHMD>/quaternion");
363363

364-
tpd.positionAction = positionAction;
365-
tpd.rotationAction = rotationAction;
364+
tpd.positionInput = new InputActionProperty(positionAction);
365+
tpd.rotationInput = new InputActionProperty(rotationAction);
366366

367367
// before render only
368368
var go1 = tpd.gameObject;
@@ -430,6 +430,71 @@ public void Components_CanUpdateGameObjectTransformThroughTrackedPoseDriver()
430430
}
431431
}
432432

433+
[Test]
434+
[Category("Components")]
435+
public void Components_TrackedPoseDriver_EnablesAndDisablesDirectActions()
436+
{
437+
var positionInput = new InputActionProperty(new InputAction(binding: "<TestHMD>/vector3"));
438+
var rotationInput = new InputActionProperty(new InputAction(binding: "<TestHMD>/quaternion"));
439+
440+
var go = new GameObject();
441+
var component = go.AddComponent<TrackedPoseDriver>();
442+
component.enabled = false;
443+
component.positionInput = positionInput;
444+
component.rotationInput = rotationInput;
445+
446+
Assert.That(positionInput.action.enabled, Is.False);
447+
Assert.That(rotationInput.action.enabled, Is.False);
448+
449+
component.enabled = true;
450+
451+
Assert.That(positionInput.action.enabled, Is.True);
452+
Assert.That(rotationInput.action.enabled, Is.True);
453+
454+
component.enabled = false;
455+
456+
Assert.That(positionInput.action.enabled, Is.False);
457+
Assert.That(rotationInput.action.enabled, Is.False);
458+
}
459+
460+
[Test]
461+
[Category("Components")]
462+
public void Components_TrackedPoseDriver_DoesNotEnableOrDisableReferenceActions()
463+
{
464+
var map = new InputActionMap("map");
465+
map.AddAction("Position", binding: "<TestHMD>/vector3");
466+
map.AddAction("Rotation", binding: "<TestHMD>/quaternion");
467+
var asset = ScriptableObject.CreateInstance<InputActionAsset>();
468+
asset.AddActionMap(map);
469+
470+
var positionReference = ScriptableObject.CreateInstance<InputActionReference>();
471+
var rotationReference = ScriptableObject.CreateInstance<InputActionReference>();
472+
positionReference.Set(asset, "map", "Position");
473+
rotationReference.Set(asset, "map", "Rotation");
474+
475+
var positionInput = new InputActionProperty(positionReference);
476+
var rotationInput = new InputActionProperty(rotationReference);
477+
478+
var go = new GameObject();
479+
var component = go.AddComponent<TrackedPoseDriver>();
480+
component.enabled = false;
481+
component.positionInput = positionInput;
482+
component.rotationInput = rotationInput;
483+
484+
Assert.That(positionInput.action.enabled, Is.False);
485+
Assert.That(rotationInput.action.enabled, Is.False);
486+
487+
component.enabled = true;
488+
489+
Assert.That(positionInput.action.enabled, Is.False);
490+
Assert.That(rotationInput.action.enabled, Is.False);
491+
492+
component.enabled = false;
493+
494+
Assert.That(positionInput.action.enabled, Is.False);
495+
Assert.That(rotationInput.action.enabled, Is.False);
496+
}
497+
433498
[Test]
434499
[Category("Layouts")]
435500
public void Layouts_PoseControlsCanBeCreatedBySubcontrols()

Packages/com.unity.inputsystem/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ however, it has to be formatted properly to pass verification tests.
1212

1313
### Changed
1414

15+
- Changed `TrackedPoseDriver` to use properties of type `InputActionProperty` rather than `InputAction` to allow more flexibility.
16+
- XRLayoutBuilder now supports `_` in sanitized names.
1517
- Added method `SetMotorSpeedsAndLightBarColor` as a workaround for setting both the light bar and motor speeds simultaneously on a DualShock 4 controller ([case 1271119](https://issuetracker.unity3d.com/issues/dualshock4-setlightbarcolor-and-setmotorspeeds-cannot-be-called-on-the-same-frame-using-input-system)).
1618
- Updated documentation for sensor WebGL support in 2021.2.
1719

Packages/com.unity.inputsystem/InputSystem/InputUpdateType.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace UnityEngine.InputSystem.LowLevel
77
{
88
/// <summary>
9-
/// Enum of different player loop positions where the input system can invoke it's update mechanism.
9+
/// Enum of different player loop positions where the input system can invoke its update mechanism.
1010
/// </summary>
1111
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1714:FlagsEnumsShouldHavePluralNames", Justification = "Not consistently used as flags, many using APIs expect only one type to be passed.")]
1212
[Flags]

Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public void EnableJoining()
313313
else
314314
{
315315
Debug.LogError(
316-
"No join action configured on PlayerInputManager but join behavior is set to JoinPlayersWhenActionIsTriggered",
316+
$"No join action configured on PlayerInputManager but join behavior is set to {nameof(PlayerJoinBehavior.JoinPlayersWhenJoinActionIsTriggered)}",
317317
this);
318318
}
319319
break;

0 commit comments

Comments
 (0)