Skip to content

Commit 030f38b

Browse files
author
Rene Damm
authored
FIX: User-contributed fixes (#1477).
1 parent 9a76136 commit 030f38b

6 files changed

Lines changed: 33 additions & 21 deletions

File tree

Assets/Tests/InputSystem/CoreTests_Editor.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,6 +2167,9 @@ public void Editor_ActionTree_CompositesAreShownWithNiceNames()
21672167
.With("Negative", "<Keyboard>/a")
21682168
.With("Positive", "<Keyboard>/b");
21692169

2170+
// Wipe name that AddCompositeBinding assigned.
2171+
action.ChangeBinding(0).WithName(null);
2172+
21702173
var so = new SerializedObject(asset);
21712174
var tree = new InputActionTreeView(so)
21722175
{

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ however, it has to be formatted properly to pass verification tests.
4141
* This fix relies on a `CanvasGroup` being injected into each `playerRoot` and the `interactable` property of the group being toggled back and forth depending on which part of the UI is being updated.
4242
- Fixed `InputTestFixture` incorrectly running input updates out of sync with the player loop ([case 1341740](https://issuetracker.unity3d.com/issues/buttoncontrol-dot-waspressedthisframe-is-false-when-using-inputtestfixture-dot-press)).
4343
* This had effects such as `InputAction.WasPressedThisFrame()` returning false expectedly.
44+
- Fixed broken code example for state structs in `Devices.md` documentation (fix contributed by [jeffreylanters](https://github.com/jeffreylanters)).
45+
- Fixed `TrackedDeviceRaycaster` not picking closest hit in scene (fix originally contributed by [alexboost222](https://github.com/alexboost222)).
4446

4547
#### Actions
4648

@@ -58,6 +60,7 @@ however, it has to be formatted properly to pass verification tests.
5860
- Fixed control schemes of bindings not getting updates when being pasted from one `.inputactions` asset into another ([case 1276106](https://issuetracker.unity3d.com/issues/input-system-control-schemes-are-not-resolved-when-copying-bindings-between-inputactionassets)).
5961
* For example, if you copied a binding from an asset that had a "Gamepad" control scheme into an asset that had none, the resulting binding would be unusable.
6062
* All associations with control schemes that do not exist in the target asset are now removed from bindings upon pasting.
63+
- Fixed `InputActionSetupExtensions.AddCompositeBinding` not setting name of composite.
6164

6265
## [1.2.0] - 2021-10-22
6366

Packages/com.unity.inputsystem/Documentation~/Devices.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public struct MyDeviceState : IInputStateTypeInfo
299299
// You must tag every state with a FourCC code for type
300300
// checking. The characters can be anything. Choose something that allows
301301
// you to easily recognize memory that belongs to your own Device.
302-
public FourCC format => return new FourCC('M', 'Y', 'D', 'V');
302+
public FourCC format => new FourCC('M', 'Y', 'D', 'V');
303303

304304
// InputControlAttributes on fields tell the Input System to create Controls
305305
// for the public fields found in the struct.

Packages/com.unity.inputsystem/InputSystem/Actions/InputActionSetupExtensions.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,16 @@ public static CompositeSyntax AddCompositeBinding(this InputAction action, strin
479479

480480
var actionMap = action.GetOrCreateActionMap();
481481

482-
////REVIEW: use 'name' instead of 'path' field here?
483-
var binding = new InputBinding {path = composite, interactions = interactions, processors = processors, isComposite = true, action = action.name};
482+
var binding = new InputBinding
483+
{
484+
name = NameAndParameters.ParseName(composite),
485+
path = composite,
486+
interactions = interactions,
487+
processors = processors,
488+
isComposite = true,
489+
action = action.name
490+
};
491+
484492
var bindingIndex = AddBindingInternal(actionMap, binding);
485493
return new CompositeSyntax(actionMap, action, bindingIndex);
486494
}

Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionTreeViewItems.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Linq;
55
using UnityEditor;
66
using UnityEditor.IMGUI.Controls;
7+
using UnityEngine.InputSystem.Utilities;
78

89
////TODO: sync expanded state of SerializedProperties to expanded state of tree (will help preserving expansion in inspector)
910

@@ -461,6 +462,8 @@ public CompositeBindingTreeItem(SerializedProperty bindingProperty)
461462
public override GUIStyle colorTagStyle => Styles.blueRect;
462463
public override bool canRename => true;
463464

465+
public string compositeName => NameAndParameters.ParseName(path);
466+
464467
public override void Rename(string newName)
465468
{
466469
InputActionSerializationHelpers.RenameComposite(property, newName);
@@ -503,7 +506,10 @@ public override bool GetDropLocation(Type itemType, int? childIndex, ref Seriali
503506
var item = new CompositeBindingTreeItem(bindingProperty);
504507

505508
item.depth = parent.depth + 1;
506-
item.displayName = !string.IsNullOrEmpty(item.name) ? item.name : ObjectNames.NicifyVariableName(item.path);
509+
item.displayName = !string.IsNullOrEmpty(item.name)
510+
? item.name
511+
: ObjectNames.NicifyVariableName(NameAndParameters.ParseName(item.path));
512+
507513
parent.AddChild(item);
508514

509515
return item;
@@ -531,7 +537,7 @@ public override string expectedControlLayout
531537
if (m_ExpectedControlLayout == null)
532538
{
533539
var partName = name;
534-
var compositeName = ((CompositeBindingTreeItem)parent).name;
540+
var compositeName = ((CompositeBindingTreeItem)parent).compositeName;
535541
var layoutName = InputBindingComposite.GetExpectedControlLayoutName(compositeName, partName);
536542
m_ExpectedControlLayout = layoutName ?? "";
537543
}

Packages/com.unity.inputsystem/InputSystem/Plugins/UI/TrackedDeviceRaycaster.cs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ public override void Raycast(PointerEventData eventData, List<RaycastResult> res
9696
PerformRaycast(trackedEventData, resultAppendList);
9797
}
9898

99-
// Use this list on each raycast to avoid continually allocating.
100-
[NonSerialized]
101-
private List<RaycastHitData> m_RaycastResultsCache = new List<RaycastHitData>();
99+
// Cached instances for raycasts hits to minimize GC.
100+
[NonSerialized] private List<RaycastHitData> m_RaycastResultsCache = new List<RaycastHitData>();
102101

103102
internal void PerformRaycast(ExtendedPointerEventData eventData, List<RaycastResult> resultAppendList)
104103
{
@@ -114,25 +113,18 @@ internal void PerformRaycast(ExtendedPointerEventData eventData, List<RaycastRes
114113
#if UNITY_INPUT_SYSTEM_ENABLE_PHYSICS
115114
if (m_CheckFor3DOcclusion)
116115
{
117-
var hits = Physics.RaycastAll(ray, hitDistance, m_BlockingMask);
118-
119-
if (hits.Length > 0 && hits[0].distance < hitDistance)
120-
{
121-
hitDistance = hits[0].distance;
122-
}
116+
if (Physics.Raycast(ray, out var hit, maxDistance: hitDistance, layerMask: m_BlockingMask))
117+
hitDistance = hit.distance;
123118
}
124119
#endif
125120

126121
#if UNITY_INPUT_SYSTEM_ENABLE_PHYSICS2D
127122
if (m_CheckFor2DOcclusion)
128123
{
129124
var raycastDistance = hitDistance;
130-
var hits = Physics2D.GetRayIntersectionAll(ray, raycastDistance, m_BlockingMask);
131-
132-
if (hits.Length > 0 && hits[0].fraction * raycastDistance < hitDistance)
133-
{
134-
hitDistance = hits[0].fraction * raycastDistance;
135-
}
125+
var hits = Physics2D.GetRayIntersection(ray, raycastDistance, m_BlockingMask);
126+
if (hits.collider != null)
127+
hitDistance = hits.distance;
136128
}
137129
#endif
138130

@@ -176,7 +168,7 @@ internal void PerformRaycast(ExtendedPointerEventData eventData, List<RaycastRes
176168

177169
internal static InlinedArray<TrackedDeviceRaycaster> s_Instances;
178170

179-
static readonly List<RaycastHitData> s_SortedGraphics = new List<RaycastHitData>();
171+
private static readonly List<RaycastHitData> s_SortedGraphics = new List<RaycastHitData>();
180172
private void SortedRaycastGraphics(Canvas canvas, Ray ray, List<RaycastHitData> results)
181173
{
182174
var graphics = GraphicRegistry.GetGraphicsForCanvas(canvas);

0 commit comments

Comments
 (0)