@@ -55,7 +55,7 @@ public void PlayerInput_CanInstantiatePlayer()
5555
5656 Assert . That ( player , Is . Not . Null ) ;
5757 Assert . That ( player . playerIndex , Is . EqualTo ( 0 ) ) ;
58- Assert . That ( player . actions , Is . SameAs ( prefabPlayerInput . actions ) ) ;
58+ Assert . That ( player . actions . actionMaps . Count , Is . EqualTo ( prefabPlayerInput . actions . actionMaps . Count ) ) ;
5959 Assert . That ( player . devices , Is . EquivalentTo ( new [ ] { gamepad } ) ) ;
6060 Assert . That ( player . currentControlScheme , Is . EqualTo ( "Gamepad" ) ) ;
6161 }
@@ -108,7 +108,6 @@ public void PlayerInput_CanLinkSpecificDeviceToUI()
108108 var ui = prefab . AddComponent < InputSystemUIInputModule > ( ) ;
109109 player . uiInputModule = ui ;
110110 player . actions = InputActionAsset . FromJson ( kActions ) ;
111- ui . actionsAsset = player . actions ;
112111
113112 InputSystem . AddDevice < Gamepad > ( ) ;
114113 InputSystem . AddDevice < Keyboard > ( ) ;
@@ -117,6 +116,7 @@ public void PlayerInput_CanLinkSpecificDeviceToUI()
117116 var gamepad = InputSystem . AddDevice < Gamepad > ( ) ;
118117
119118 var instance = PlayerInput . Instantiate ( prefab , pairWithDevices : gamepad ) ;
119+ ui . actionsAsset = instance . actions ;
120120
121121 Assert . That ( instance . devices , Is . EquivalentTo ( new [ ] { gamepad } ) ) ;
122122 Assert . That ( ui . actionsAsset . devices , Is . EquivalentTo ( new [ ] { gamepad } ) ) ;
@@ -149,11 +149,11 @@ public void PlayerInput_CanUseSameActionsForUIInputModule()
149149 eventSystemGO . SetActive ( true ) ;
150150 playerGO . SetActive ( true ) ;
151151
152- Assert . That ( actions . FindActionMap ( "Gameplay" ) . enabled , Is . True ) ;
153- Assert . That ( actions . FindActionMap ( "UI" ) . enabled , Is . True ) ;
154- Assert . That ( actions [ "UI/Navigate" ] . controls , Is . Empty ) ;
155- Assert . That ( actions [ "UI/Point" ] . controls , Is . EquivalentTo ( new [ ] { mouse . position } ) ) ;
156- Assert . That ( actions [ "UI/Click" ] . controls , Is . EquivalentTo ( new [ ] { mouse . leftButton } ) ) ;
152+ Assert . That ( player . actions . FindActionMap ( "Gameplay" ) . enabled , Is . True ) ;
153+ Assert . That ( uiModule . actionsAsset . FindActionMap ( "UI" ) . enabled , Is . True ) ;
154+ Assert . That ( uiModule . actionsAsset [ "UI/Navigate" ] . controls , Is . Empty ) ;
155+ Assert . That ( uiModule . actionsAsset [ "UI/Point" ] . controls , Is . EquivalentTo ( new [ ] { mouse . position } ) ) ;
156+ Assert . That ( uiModule . actionsAsset [ "UI/Click" ] . controls , Is . EquivalentTo ( new [ ] { mouse . leftButton } ) ) ;
157157 }
158158
159159 [ Test ]
@@ -391,7 +391,23 @@ public void PlayerInput_CanAssignActionsToPlayer()
391391 var actions = InputActionAsset . FromJson ( kActions ) ;
392392 playerInput . actions = actions ;
393393
394- Assert . That ( playerInput . actions , Is . SameAs ( actions ) ) ;
394+ Assert . That ( playerInput . actions . actionMaps . Count , Is . EqualTo ( actions . actionMaps . Count ) ) ;
395+ Assert . That ( playerInput . actions . actionMaps [ 0 ] . name , Is . EqualTo ( actions . actionMaps [ 0 ] . name ) ) ;
396+ }
397+
398+ [ Test ]
399+ [ Category ( "PlayerInput" ) ]
400+ public void PlayerInput_CopiesActionAssetForFirstPlayer ( )
401+ {
402+ var go = new GameObject ( ) ;
403+ var playerInput = go . AddComponent < PlayerInput > ( ) ;
404+
405+ var actions = InputActionAsset . FromJson ( kActions ) ;
406+ playerInput . actions = actions ;
407+
408+ Assert . That ( playerInput . actions . actionMaps . Count , Is . EqualTo ( actions . actionMaps . Count ) ) ;
409+ Assert . That ( playerInput . actions . actionMaps [ 0 ] . name , Is . EqualTo ( actions . actionMaps [ 0 ] . name ) ) ;
410+ Assert . That ( playerInput . actions . GetInstanceID ( ) , ! Is . EqualTo ( actions . GetInstanceID ( ) ) ) ;
395411 }
396412
397413 [ Test ]
@@ -407,13 +423,13 @@ public void PlayerInput_AssigningNewActionsToPlayer_DisablesExistingActions()
407423 playerInput . defaultActionMap = "gameplay" ;
408424 playerInput . actions = actions1 ;
409425
410- Assert . That ( actions1 . actionMaps [ 0 ] . enabled , Is . True ) ;
411- Assert . That ( actions2 . actionMaps [ 0 ] . enabled , Is . False ) ;
426+ Assert . That ( playerInput . actions . actionMaps [ 0 ] . enabled , Is . True ) ;
427+ Assert . That ( actions1 . actionMaps [ 0 ] . enabled , Is . False ) ;
412428
413429 playerInput . actions = actions2 ;
414430
415- Assert . That ( actions1 . actionMaps [ 0 ] . enabled , Is . False ) ;
416- Assert . That ( actions2 . actionMaps [ 0 ] . enabled , Is . True ) ;
431+ Assert . That ( actions2 . actionMaps [ 0 ] . enabled , Is . False ) ;
432+ Assert . That ( playerInput . actions . actionMaps [ 0 ] . enabled , Is . True ) ;
417433 }
418434
419435 [ Test ]
@@ -1714,7 +1730,8 @@ InputDevice[] AddDevices()
17141730
17151731 // Make sure that no cloning of actions happened on the prefab.
17161732 // https://fogbugz.unity3d.com/f/cases/1319756/
1717- Assert . That ( playerPrefab . GetComponent < PlayerInput > ( ) . actions , Is . SameAs ( playerPrefabActions ) ) ;
1733+
1734+ Assert . That ( playerPrefab . GetComponent < PlayerInput > ( ) . actions . actionMaps . Count , Is . EqualTo ( playerPrefabActions . actionMaps . Count ) ) ;
17181735 Assert . That ( playerPrefab . GetComponent < PlayerInput > ( ) . m_ActionsInitialized , Is . False ) ;
17191736 }
17201737
@@ -2421,13 +2438,13 @@ public void PlayerInput_DelegatesAreUpdate_WhenActionMapAddedAfterAssignment()
24212438 // Disable the asset while adding another action map to it as none
24222439 // of the actions in the asset can be enabled during modification
24232440 //
2424- actionAsset . Disable ( ) ;
2441+ playerInput . actions . Disable ( ) ;
24252442 var keyboard = InputSystem . AddDevice < Keyboard > ( ) ;
2426- var newActionMap = actionAsset . AddActionMap ( "NewMap" ) ;
2443+ var newActionMap = playerInput . actions . AddActionMap ( "NewMap" ) ;
24272444 var newAction = newActionMap . AddAction ( "NewAction" ) ;
24282445 newAction . AddBinding ( "<Keyboard>/k" , groups : "Keyboard" ) ;
2429- actionAsset . AddControlScheme ( "Keyboard" ) . WithRequiredDevice < Keyboard > ( ) ;
2430- actionAsset . Enable ( ) ;
2446+ playerInput . actions . AddControlScheme ( "Keyboard" ) . WithRequiredDevice < Keyboard > ( ) ;
2447+ playerInput . actions . Enable ( ) ;
24312448
24322449 playerInput . currentActionMap = newActionMap ;
24332450 playerInput . ActivateInput ( ) ;
0 commit comments