Skip to content

Commit 1272cbd

Browse files
authored
Fix: Fixed using the input system in il2cpp when managed stripping le… (#811)
1 parent c65234a commit 1272cbd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+106
-0
lines changed

Assets/Tests/InputSystem/APIVerificationTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,17 @@ public void API_MethodReturnTypesAreNotIntPtr()
136136
Assert.That(intptrMethods, Is.Empty);
137137
}
138138

139+
[Test]
140+
[Category("API")]
141+
public void API_ControlTypesHavePreserveAttribute()
142+
{
143+
var controlType = typeof(InputControl);
144+
var controlTypes = controlType.Assembly.GetTypes().Where(t => controlType.IsAssignableFrom(t));
145+
Assert.That(controlTypes, Is.Not.Empty);
146+
var controlTypesWithoutPreserveAttribute = controlTypes.Where(t => !t.CustomAttributes.Any(a => a.AttributeType.Name.Contains("PreserveAttribute")));
147+
Assert.That(controlTypesWithoutPreserveAttribute, Is.Empty);
148+
}
149+
139150
[Test]
140151
[Category("API")]
141152
public void API_MethodParameterTypesAreNotIntPtr()

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ however, it has to be formatted properly to pass verification tests.
1313

1414
- Don't pass events for null devices (for devices which have not been created) to `InputSystem.onEvent` callbacks.
1515
- Will close debugger input state windows, when the state is no longer valid instead of throwing exceptions.
16+
- Fixed using the input system in il2cpp when managed stripping level is set higher then "Low".
1617
- Device debugger window will still show when reading from specific controls throws exceptions.
1718
- Offsets and sizes for elements on Linux joysticks are now computed correctly.
1819
- Joysticks now have a deadzone processor on the stick itself.

Packages/com.unity.inputsystem/InputSystem/Controls/AnyKeyControl.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace UnityEngine.InputSystem.Controls
99
/// returns 1.0; otherwise it returns 0.0.
1010
/// </summary>
1111
[InputControlLayout(hideInUI = true)]
12+
[UnityEngine.Scripting.Preserve]
1213
public class AnyKeyControl : ButtonControl
1314
{
1415
////TODO: wasPressedThisFrame and wasReleasedThisFrame

Packages/com.unity.inputsystem/InputSystem/Controls/AxisControl.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace UnityEngine.InputSystem.Controls
1313
/// Can optionally be configured to perform normalization.
1414
/// Stored as either a float, a short, a byte, or a single bit.
1515
/// </remarks>
16+
[UnityEngine.Scripting.Preserve]
1617
public class AxisControl : InputControl<float>
1718
{
1819
public enum Clamp

Packages/com.unity.inputsystem/InputSystem/Controls/ButtonControl.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace UnityEngine.InputSystem.Controls
1515
/// doing so brings many benefits through allowing code to flexibly target buttons
1616
/// and axes the same way.
1717
/// </remarks>
18+
[UnityEngine.Scripting.Preserve]
1819
public class ButtonControl : AxisControl
1920
{
2021
public float pressPoint;

Packages/com.unity.inputsystem/InputSystem/Controls/DiscreteButtonControl.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace UnityEngine.InputSystem.Controls
1717
/// the value 1 could indicate that the switch is moved to the left whereas 3 could indicate it is
1818
/// moved up.
1919
/// </remarks>
20+
[Scripting.Preserve]
2021
public class DiscreteButtonControl : ButtonControl
2122
{
2223
/// <summary>

Packages/com.unity.inputsystem/InputSystem/Controls/DoubleControl.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace UnityEngine.InputSystem.Controls
55
/// <summary>
66
/// A control reading a <see cref="double"/>.
77
/// </summary>
8+
[Scripting.Preserve]
89
public class DoubleControl : InputControl<double>
910
{
1011
public DoubleControl()

Packages/com.unity.inputsystem/InputSystem/Controls/DpadControl.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ namespace UnityEngine.InputSystem.Controls
1515
/// even if pressing diagonally, the vector will have a length of 1 (instead
1616
/// of reading something like <c>(1,1)</c> for example).
1717
/// </remarks>
18+
[Scripting.Preserve]
1819
public class DpadControl : Vector2Control
1920
{
2021
[InputControlLayout(hideInUI = true)]
22+
[Scripting.Preserve]
2123
internal class DpadAxisControl : AxisControl
2224
{
2325
public int component;

Packages/com.unity.inputsystem/InputSystem/Controls/InputControl.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ namespace UnityEngine.InputSystem
9999
/// <seealso cref="InputControlPath"/>
100100
/// <seealso cref="InputStateBlock"/>
101101
[DebuggerDisplay("{DebuggerDisplay(),nq}")]
102+
[Scripting.Preserve]
102103
public abstract class InputControl
103104
{
104105
/// <summary>
@@ -844,6 +845,7 @@ internal virtual void ClearProcessors()
844845
/// <typeparam name="TValue">Type of value captured by the control. Note that this does not mean
845846
/// that the control has to store data in the given value format. A control that captures float
846847
/// values, for example, may be stored in state as byte values instead.</typeparam>
848+
[Scripting.Preserve]
847849
public abstract class InputControl<TValue> : InputControl
848850
where TValue : struct
849851
{

Packages/com.unity.inputsystem/InputSystem/Controls/InputControlLayoutAttribute.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using UnityEngine.Scripting;
23

34
////REVIEW: should this *not* be inherited? inheritance can lead to surprises
45

0 commit comments

Comments
 (0)