@@ -55,7 +55,7 @@ public void PlayerInput_CanInstantiatePlayer()
55
55
56
56
Assert . That ( player , Is . Not . Null ) ;
57
57
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 ) ) ;
59
59
Assert . That ( player . devices , Is . EquivalentTo ( new [ ] { gamepad } ) ) ;
60
60
Assert . That ( player . currentControlScheme , Is . EqualTo ( "Gamepad" ) ) ;
61
61
}
@@ -108,7 +108,6 @@ public void PlayerInput_CanLinkSpecificDeviceToUI()
108
108
var ui = prefab . AddComponent < InputSystemUIInputModule > ( ) ;
109
109
player . uiInputModule = ui ;
110
110
player . actions = InputActionAsset . FromJson ( kActions ) ;
111
- ui . actionsAsset = player . actions ;
112
111
113
112
InputSystem . AddDevice < Gamepad > ( ) ;
114
113
InputSystem . AddDevice < Keyboard > ( ) ;
@@ -117,6 +116,7 @@ public void PlayerInput_CanLinkSpecificDeviceToUI()
117
116
var gamepad = InputSystem . AddDevice < Gamepad > ( ) ;
118
117
119
118
var instance = PlayerInput . Instantiate ( prefab , pairWithDevices : gamepad ) ;
119
+ ui . actionsAsset = instance . actions ;
120
120
121
121
Assert . That ( instance . devices , Is . EquivalentTo ( new [ ] { gamepad } ) ) ;
122
122
Assert . That ( ui . actionsAsset . devices , Is . EquivalentTo ( new [ ] { gamepad } ) ) ;
@@ -149,11 +149,11 @@ public void PlayerInput_CanUseSameActionsForUIInputModule()
149
149
eventSystemGO . SetActive ( true ) ;
150
150
playerGO . SetActive ( true ) ;
151
151
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 } ) ) ;
157
157
}
158
158
159
159
[ Test ]
@@ -391,7 +391,23 @@ public void PlayerInput_CanAssignActionsToPlayer()
391
391
var actions = InputActionAsset . FromJson ( kActions ) ;
392
392
playerInput . actions = actions ;
393
393
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 ( ) ) ) ;
395
411
}
396
412
397
413
[ Test ]
@@ -407,13 +423,13 @@ public void PlayerInput_AssigningNewActionsToPlayer_DisablesExistingActions()
407
423
playerInput . defaultActionMap = "gameplay" ;
408
424
playerInput . actions = actions1 ;
409
425
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 ) ;
412
428
413
429
playerInput . actions = actions2 ;
414
430
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 ) ;
417
433
}
418
434
419
435
[ Test ]
@@ -1714,7 +1730,8 @@ InputDevice[] AddDevices()
1714
1730
1715
1731
// Make sure that no cloning of actions happened on the prefab.
1716
1732
// 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 ) ) ;
1718
1735
Assert . That ( playerPrefab . GetComponent < PlayerInput > ( ) . m_ActionsInitialized , Is . False ) ;
1719
1736
}
1720
1737
@@ -2421,13 +2438,13 @@ public void PlayerInput_DelegatesAreUpdate_WhenActionMapAddedAfterAssignment()
2421
2438
// Disable the asset while adding another action map to it as none
2422
2439
// of the actions in the asset can be enabled during modification
2423
2440
//
2424
- actionAsset . Disable ( ) ;
2441
+ playerInput . actions . Disable ( ) ;
2425
2442
var keyboard = InputSystem . AddDevice < Keyboard > ( ) ;
2426
- var newActionMap = actionAsset . AddActionMap ( "NewMap" ) ;
2443
+ var newActionMap = playerInput . actions . AddActionMap ( "NewMap" ) ;
2427
2444
var newAction = newActionMap . AddAction ( "NewAction" ) ;
2428
2445
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 ( ) ;
2431
2448
2432
2449
playerInput . currentActionMap = newActionMap ;
2433
2450
playerInput . ActivateInput ( ) ;
0 commit comments