Skip to content

Commit 7594a3a

Browse files
CHANGE: Remove code that supported Unity versions older than 2022 LTS (#2274)
Co-authored-by: u-pr-agent[bot] <205906871+u-pr-agent[bot]@users.noreply.github.com>
1 parent cd1c631 commit 7594a3a

File tree

8 files changed

+26
-87
lines changed

8 files changed

+26
-87
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ however, it has to be formatted properly to pass verification tests.
1010

1111
## [Unreleased] - yyyy-mm-dd
1212

13+
### Changed
14+
- Removed code that had to do with Unity versions older than Unity 2022.3 LTS.
15+
1316
### Fixed
1417
- An issue where a UITK MouseEvent was triggered when changing from Scene View to Game View in the Editor has been fixed. [ISXB-1671](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1671)
1518

Packages/com.unity.inputsystem/InputSystem/Editor/DeviceSimulator/InputSystemPlugin.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,10 @@ public override void OnDestroy()
107107
{
108108
// Note that m_Quitting is used here to mitigate the problem reported in issue tracker:
109109
// https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-10774.
110-
// Enabling a device will call into IOCTL of backend which will (may) be destroyed prior
111-
// to this callback on Unity version <= 2022.2. This is not a fix for the actual problem
110+
// Enabling a device will call into IOCTL of backend which may be destroyed prior
111+
// to this callback on Unity version. This is not a fix for the actual problem
112112
// of shutdown order but a package fix to mitigate this problem.
113+
// The core problem with the destruction order was still there in Unity 6.5.
113114
if (device.added && !m_Quitting)
114115
InputSystem.EnableDevice(device);
115116
}

Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemPluginControl.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,8 @@ private static void CheckForExtension()
3737
BuildTarget.tvOS,
3838
BuildTarget.LinuxHeadlessSimulation,
3939
BuildTarget.EmbeddedLinux,
40-
#if UNITY_2022_1_OR_NEWER
4140
BuildTarget.QNX,
42-
#endif
43-
#if UNITY_2022_3_OR_NEWER
4441
BuildTarget.VisionOS,
45-
#endif
4642
(BuildTarget)49,
4743
BuildTarget.NoTarget
4844
};

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ public override string ToString()
9494
stringBuilder.AppendLine("azimuthAngle: " + azimuthAngle);
9595
stringBuilder.AppendLine("altitudeAngle: " + altitudeAngle);
9696
stringBuilder.AppendLine("twist: " + twist);
97-
#if UNITY_2022_3_OR_NEWER
9897
stringBuilder.AppendLine("displayIndex: " + displayIndex);
99-
#endif
10098
return stringBuilder.ToString();
10199
}
102100

@@ -138,27 +136,21 @@ internal void ReadDeviceState()
138136
azimuthAngle = (pen.tilt.value.x + 1) * Mathf.PI / 2;
139137
altitudeAngle = (pen.tilt.value.y + 1) * Mathf.PI / 2;
140138
twist = pen.twist.value * Mathf.PI * 2;
141-
#if UNITY_2022_3_OR_NEWER
142139
displayIndex = pen.displayIndex.ReadValue();
143-
#endif
144140
}
145141
else if (control.parent is TouchControl touchControl)
146142
{
147143
uiToolkitPointerId = GetTouchPointerId(touchControl);
148144
pressure = touchControl.pressure.magnitude;
149145
radius = touchControl.radius.value;
150-
#if UNITY_2022_3_OR_NEWER
151146
displayIndex = touchControl.displayIndex.ReadValue();
152-
#endif
153147
}
154148
else if (control.parent is Touchscreen touchscreen)
155149
{
156150
uiToolkitPointerId = GetTouchPointerId(touchscreen.primaryTouch);
157151
pressure = touchscreen.pressure.magnitude;
158152
radius = touchscreen.radius.value;
159-
#if UNITY_2022_3_OR_NEWER
160153
displayIndex = touchscreen.displayIndex.ReadValue();
161-
#endif
162154
}
163155
else
164156
{

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

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -579,9 +579,8 @@ private void ProcessPointerMovement(ExtendedPointerEventData eventData, GameObje
579579
if (!sendPointerHoverToParent && current == pointerParent)
580580
break;
581581

582-
#if UNITY_2021_3_OR_NEWER
583582
eventData.fullyExited = current != commonRoot && eventData.pointerEnter != currentPointerTarget;
584-
#endif
583+
585584
ExecuteEvents.Execute(current.gameObject, eventData, ExecuteEvents.pointerExitHandler);
586585
eventData.hovered.Remove(current.gameObject);
587586

@@ -605,12 +604,10 @@ private void ProcessPointerMovement(ExtendedPointerEventData eventData, GameObje
605604
Transform current = currentPointerTarget.transform;
606605
while (current != null && !PointerShouldIgnoreTransform(current))
607606
{
608-
#if UNITY_2021_3_OR_NEWER
609607
eventData.reentered = current == commonRoot && current != oldPointerEnter;
610608
// if we are sending the event to parent, they are already in hover mode at that point. No need to bubble up the event.
611609
if (sendPointerHoverToParent && eventData.reentered)
612610
break;
613-
#endif
614611

615612
ExecuteEvents.Execute(current.gameObject, eventData, ExecuteEvents.pointerEnterHandler);
616613
if (wasMoved)
@@ -1926,9 +1923,7 @@ private int GetPointerStateIndexFor(InputControl control, bool createIfNotExists
19261923
eventData.pointerType = pointerType;
19271924
eventData.pointerId = pointerId;
19281925
eventData.touchId = touchId;
1929-
#if UNITY_2022_3_OR_NEWER
19301926
eventData.displayIndex = displayIndex;
1931-
#endif
19321927

19331928
// Make sure these don't linger around when we switch to a different kind of pointer.
19341929
eventData.trackedDeviceOrientation = default;
@@ -2031,9 +2026,7 @@ private int AllocatePointer(int pointerId, int displayIndex, int touchId, UIPoin
20312026
eventData = new ExtendedPointerEventData(eventSystem);
20322027

20332028
eventData.pointerId = pointerId;
2034-
#if UNITY_2022_3_OR_NEWER
20352029
eventData.displayIndex = displayIndex;
2036-
#endif
20372030
eventData.touchId = touchId;
20382031
eventData.pointerType = pointerType;
20392032
eventData.control = control;
@@ -2164,9 +2157,7 @@ private void OnPointCallback(InputAction.CallbackContext context)
21642157

21652158
ref var state = ref GetPointerStateForIndex(index);
21662159
state.screenPosition = context.ReadValue<Vector2>();
2167-
#if UNITY_2022_3_OR_NEWER
21682160
state.eventData.displayIndex = GetDisplayIndexFor(context.control);
2169-
#endif
21702161
}
21712162

21722163
// NOTE: In the click events, we specifically react to the Canceled phase to make sure we do NOT perform
@@ -2195,9 +2186,7 @@ private void OnLeftClickCallback(InputAction.CallbackContext context)
21952186
state.changedThisFrame = true;
21962187
if (IgnoreNextClick(ref context, wasPressed))
21972188
state.leftButton.ignoreNextClick = true;
2198-
#if UNITY_2022_3_OR_NEWER
21992189
state.eventData.displayIndex = GetDisplayIndexFor(context.control);
2200-
#endif
22012190
}
22022191

22032192
private void OnRightClickCallback(InputAction.CallbackContext context)
@@ -2212,9 +2201,7 @@ private void OnRightClickCallback(InputAction.CallbackContext context)
22122201
state.changedThisFrame = true;
22132202
if (IgnoreNextClick(ref context, wasPressed))
22142203
state.rightButton.ignoreNextClick = true;
2215-
#if UNITY_2022_3_OR_NEWER
22162204
state.eventData.displayIndex = GetDisplayIndexFor(context.control);
2217-
#endif
22182205
}
22192206

22202207
private void OnMiddleClickCallback(InputAction.CallbackContext context)
@@ -2229,9 +2216,7 @@ private void OnMiddleClickCallback(InputAction.CallbackContext context)
22292216
state.changedThisFrame = true;
22302217
if (IgnoreNextClick(ref context, wasPressed))
22312218
state.middleButton.ignoreNextClick = true;
2232-
#if UNITY_2022_3_OR_NEWER
22332219
state.eventData.displayIndex = GetDisplayIndexFor(context.control);
2234-
#endif
22352220
}
22362221

22372222
private bool CheckForRemovedDevice(ref InputAction.CallbackContext context)
@@ -2261,9 +2246,7 @@ private void OnScrollCallback(InputAction.CallbackContext context)
22612246
// ISXB-704: convert input value to BaseInputModule convention.
22622247
state.scrollDelta = (scrollDelta / InputSystem.scrollWheelDeltaPerTick) * scrollDeltaPerTick;
22632248

2264-
#if UNITY_2022_3_OR_NEWER
22652249
state.eventData.displayIndex = GetDisplayIndexFor(context.control);
2266-
#endif
22672250
}
22682251

22692252
private void OnMoveCallback(InputAction.CallbackContext context)
@@ -2286,9 +2269,7 @@ private void OnTrackedDeviceOrientationCallback(InputAction.CallbackContext cont
22862269

22872270
ref var state = ref GetPointerStateForIndex(index);
22882271
state.worldOrientation = context.ReadValue<Quaternion>();
2289-
#if UNITY_2022_3_OR_NEWER
22902272
state.eventData.displayIndex = GetDisplayIndexFor(context.control);
2291-
#endif
22922273
}
22932274

22942275
private void OnTrackedDevicePositionCallback(InputAction.CallbackContext context)
@@ -2299,9 +2280,7 @@ private void OnTrackedDevicePositionCallback(InputAction.CallbackContext context
22992280

23002281
ref var state = ref GetPointerStateForIndex(index);
23012282
state.worldPosition = context.ReadValue<Vector3>();
2302-
#if UNITY_2022_3_OR_NEWER
23032283
state.eventData.displayIndex = GetDisplayIndexFor(context.control);
2304-
#endif
23052284
}
23062285

23072286
private void OnControlsChanged(object obj)

Packages/com.unity.inputsystem/InputSystem/Plugins/XInput/XboxGamepadMacOS.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,6 @@ public enum Button
127127
RightThumbstickPress = 15,
128128
}
129129

130-
// IL2CPP on 2021 doesn't respect the FieldOffsets - as such, we need some padding fields
131-
#if UNITY_2021 && ENABLE_IL2CPP
132-
[FieldOffset(0)]
133-
private uint padding;
134-
#endif
135-
136130
[InputControl(name = "buttonSouth", bit = (uint)Button.A, displayName = "A")]
137131
[InputControl(name = "buttonEast", bit = (uint)Button.B, displayName = "B")]
138132
[InputControl(name = "buttonWest", bit = (uint)Button.X, displayName = "X")]
@@ -154,20 +148,9 @@ public enum Button
154148
[InputControl(name = "leftTrigger", format = "BYTE")]
155149
[FieldOffset(6)] public byte leftTrigger;
156150

157-
#if UNITY_2021 && ENABLE_IL2CPP
158-
[FieldOffset(7)]
159-
private byte triggerPadding;
160-
#endif
161-
162151
[InputControl(name = "rightTrigger", format = "BYTE")]
163152
[FieldOffset(8)] public byte rightTrigger;
164153

165-
#if UNITY_2021 && ENABLE_IL2CPP
166-
[FieldOffset(9)]
167-
private byte triggerPadding2;
168-
#endif
169-
170-
171154
[InputControl(name = "leftStick", layout = "Stick", format = "VC2S")]
172155
[InputControl(name = "leftStick/x", offset = 0, format = "SHRT", parameters = "")]
173156
[InputControl(name = "leftStick/left", offset = 0, format = "SHRT", parameters = "")]

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -587,26 +587,26 @@ protected virtual void SetLocalTransform(Vector3 newPosition, Quaternion newRota
587587
var positionValid = m_IgnoreTrackingState || (m_CurrentTrackingState & TrackingStates.Position) != 0;
588588
var rotationValid = m_IgnoreTrackingState || (m_CurrentTrackingState & TrackingStates.Rotation) != 0;
589589

590-
#if HAS_SET_LOCAL_POSITION_AND_ROTATION
591-
if (m_TrackingType == TrackingType.RotationAndPosition && rotationValid && positionValid)
590+
switch (m_TrackingType)
592591
{
593-
transform.SetLocalPositionAndRotation(newPosition, newRotation);
594-
return;
595-
}
596-
#endif
597-
598-
if (rotationValid &&
599-
(m_TrackingType == TrackingType.RotationAndPosition ||
600-
m_TrackingType == TrackingType.RotationOnly))
601-
{
602-
transform.localRotation = newRotation;
603-
}
604-
605-
if (positionValid &&
606-
(m_TrackingType == TrackingType.RotationAndPosition ||
607-
m_TrackingType == TrackingType.PositionOnly))
608-
{
609-
transform.localPosition = newPosition;
592+
case TrackingType.RotationAndPosition:
593+
if (rotationValid && positionValid)
594+
transform.SetLocalPositionAndRotation(newPosition, newRotation);
595+
else if (rotationValid)
596+
transform.localRotation = newRotation;
597+
else if (positionValid)
598+
transform.localPosition = newPosition;
599+
break;
600+
601+
case TrackingType.PositionOnly:
602+
if (positionValid)
603+
transform.localPosition = newPosition;
604+
break;
605+
606+
case TrackingType.RotationOnly:
607+
if (rotationValid)
608+
transform.localRotation = newRotation;
609+
break;
610610
}
611611
}
612612

Packages/com.unity.inputsystem/InputSystem/Unity.InputSystem.asmdef

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,6 @@
5252
"expression": "1.0.0",
5353
"define": "UNITY_INPUT_SYSTEM_ENABLE_UI"
5454
},
55-
{
56-
"name": "Unity",
57-
"expression": "[2021.3.11,2022.1)",
58-
"define": "HAS_SET_LOCAL_POSITION_AND_ROTATION"
59-
},
60-
{
61-
"name": "Unity",
62-
"expression": "[2022.1.19,2022.2)",
63-
"define": "HAS_SET_LOCAL_POSITION_AND_ROTATION"
64-
},
65-
{
66-
"name": "Unity",
67-
"expression": "2022.2",
68-
"define": "HAS_SET_LOCAL_POSITION_AND_ROTATION"
69-
},
7055
{
7156
"name": "Unity",
7257
"expression": "2022.3",

0 commit comments

Comments
 (0)