55using System . Text . RegularExpressions ;
66using NUnit . Framework ;
77using UnityEngine ;
8+ using UnityEngine . Scripting ;
89using UnityEngine . InputSystem ;
910using UnityEngine . InputSystem . Composites ;
1011using UnityEngine . InputSystem . Controls ;
@@ -1389,8 +1390,16 @@ public void Actions_WithMultipleBoundControls_DriveInteractionsFromControlWithGr
13891390 // binding makes that order dependent on the order of controls in Gamepad.
13901391 //
13911392 // So in effect, we get a sequence of Performed calls here that is a little surprising.
1393+ //
1394+ // However, it also turns out that our stripping code may not keep the order of controls when rewriting the
1395+ // updated assemblies, which makes this test indeterministic in players. So we test for the specific callbacks
1396+ // only in the editor. In players, we just make sure that the first and last callbacks match our expectations.
13921397 actions = trace . ToArray ( ) ;
1398+
1399+ #if UNITY_EDITOR
13931400 Assert . That ( actions , Has . Length . EqualTo ( 5 ) ) ;
1401+ #endif
1402+
13941403 Assert . That ( actions [ 0 ] . phase , Is . EqualTo ( InputActionPhase . Started ) ) ;
13951404 Assert . That ( actions [ 0 ] . control , Is . SameAs ( gamepad . buttonSouth ) ) ;
13961405 Assert . That ( actions [ 0 ] . action , Is . SameAs ( buttonAction ) ) ;
@@ -1399,21 +1408,25 @@ public void Actions_WithMultipleBoundControls_DriveInteractionsFromControlWithGr
13991408 Assert . That ( actions [ 1 ] . control , Is . SameAs ( gamepad . buttonSouth ) ) ;
14001409 Assert . That ( actions [ 1 ] . action , Is . SameAs ( buttonAction ) ) ;
14011410 Assert . That ( actions [ 1 ] . ReadValue < float > ( ) , Is . EqualTo ( 1 ) . Within ( 0.00001 ) ) ;
1411+
1412+ #if UNITY_EDITOR
14021413 Assert . That ( actions [ 2 ] . phase , Is . EqualTo ( InputActionPhase . Performed ) ) ;
14031414 Assert . That ( actions [ 2 ] . control , Is . SameAs ( gamepad . buttonWest ) ) ; // Control immediately following buttonSouth in list of controls.
14041415 Assert . That ( actions [ 2 ] . action , Is . SameAs ( buttonAction ) ) ;
14051416 Assert . That ( actions [ 2 ] . ReadValue < float > ( ) , Is . EqualTo ( 1 ) . Within ( 0.00001 ) ) ;
1406- Assert . That ( actions [ 3 ] . phase , Is . EqualTo ( InputActionPhase . Performed ) ) ; // Control following buttonWest in list of controls.
1407- Assert . That ( actions [ 3 ] . control , Is . SameAs ( gamepad . buttonNorth ) ) ;
1408- Assert . That ( actions [ 3 ] . action , Is . SameAs ( buttonAction ) ) ;
1409- Assert . That ( actions [ 3 ] . ReadValue < float > ( ) , Is . EqualTo ( 1 ) . Within ( 0.00001 ) ) ;
1410- Assert . That ( actions [ 4 ] . phase , Is . EqualTo ( InputActionPhase . Canceled ) ) ;
1411- Assert . That ( actions [ 4 ] . control , Is . SameAs ( gamepad . buttonNorth ) ) ;
1412- Assert . That ( actions [ 4 ] . action , Is . SameAs ( buttonAction ) ) ;
1413- Assert . That ( actions [ 4 ] . ReadValue < float > ( ) , Is . Zero . Within ( 0.00001 ) ) ;
1417+ #endif
1418+
1419+ Assert . That ( actions [ actions . Length - 2 ] . phase , Is . EqualTo ( InputActionPhase . Performed ) ) ; // Last control to be actuated.
1420+ Assert . That ( actions [ actions . Length - 2 ] . control , Is . SameAs ( gamepad . buttonNorth ) ) ;
1421+ Assert . That ( actions [ actions . Length - 2 ] . action , Is . SameAs ( buttonAction ) ) ;
1422+ Assert . That ( actions [ actions . Length - 2 ] . ReadValue < float > ( ) , Is . EqualTo ( 1 ) . Within ( 0.00001 ) ) ;
1423+ Assert . That ( actions [ actions . Length - 1 ] . control , Is . SameAs ( gamepad . buttonNorth ) ) ;
1424+ Assert . That ( actions [ actions . Length - 1 ] . action , Is . SameAs ( buttonAction ) ) ;
1425+ Assert . That ( actions [ actions . Length - 1 ] . ReadValue < float > ( ) , Is . Zero . Within ( 0.00001 ) ) ;
14141426 }
14151427 }
14161428
1429+ [ Preserve ]
14171430 private class ReleaseOnlyTestInteraction : IInputInteraction < float >
14181431 {
14191432 private bool m_WaitingForRelease ;
@@ -2688,6 +2701,7 @@ public void Actions_IncompatibleProcessorIsIgnored()
26882701 }
26892702
26902703 // ReSharper disable once ClassNeverInstantiated.Local
2704+ [ Preserve ]
26912705 private class ConstantVector2TestProcessor : InputProcessor < Vector2 >
26922706 {
26932707 public override Vector2 Process ( Vector2 value , InputControl < Vector2 > control )
@@ -2876,6 +2890,7 @@ public void Actions_CanFindEnabledActions()
28762890 }
28772891
28782892 // ReSharper disable once ClassNeverInstantiated.Local
2893+ [ Preserve ]
28792894 private class TestInteraction : IInputInteraction
28802895 {
28812896#pragma warning disable CS0649
@@ -4266,6 +4281,7 @@ public void Actions_RegisteringExistingCompositeUnderNewName_CreatesAlias()
42664281 #endif // UNITY_EDITOR
42674282
42684283 #pragma warning disable CS0649
4284+ [ Preserve ]
42694285 private class CompositeWithParameters : InputBindingComposite < float >
42704286 {
42714287 public int intParameter ;
@@ -4685,6 +4701,7 @@ public void Actions_CanCreateComposite_WithPartsBeingOutOfOrder()
46854701 }
46864702 }
46874703
4704+ [ Preserve ]
46884705 private class LogInteraction : IInputInteraction
46894706 {
46904707 public void Process ( ref InputInteractionContext context )
@@ -5008,6 +5025,7 @@ public void Actions_CompositesReportControlThatTriggeredTheCompositeInCallback()
50085025 LogAssert . NoUnexpectedReceived ( ) ;
50095026 }
50105027
5028+ [ Preserve ]
50115029 private class CompositeWithVector2Part : InputBindingComposite < Vector2 >
50125030 {
50135031 [ InputControlAttribute ( layout = "Vector2" ) ]
@@ -5041,6 +5059,7 @@ public void Actions_CanCreateCompositeWithVector2PartBinding()
50415059 }
50425060 }
50435061
5062+ [ Preserve ]
50445063 private class CompositeAskingForSourceControl : InputBindingComposite < float >
50455064 {
50465065 [ InputControl ( layout = "Button" ) ]
@@ -5818,6 +5837,7 @@ public void Actions_ExceptionsInCallbacksAreCaughtAndLogged()
58185837 LogAssert . NoUnexpectedReceived ( ) ;
58195838 }
58205839
5840+ [ Preserve ]
58215841 class TestInteractionCheckingDefaultState : IInputInteraction
58225842 {
58235843 public void Process ( ref InputInteractionContext context )
0 commit comments