@@ -1346,6 +1346,63 @@ public void Actions_CanSaveAndLoadRebinds()
13461346 Assert . That ( secondActionInAsset . bindings [ 0 ] . overrideProcessors , Is . EqualTo ( "invert" ) ) ;
13471347 }
13481348
1349+ [ Test ]
1350+ [ Category ( "Actions" ) ]
1351+ public void Actions_CanSaveAndLoadRebindOnlyForOverridesSet ( )
1352+ {
1353+ var action = new InputAction ( ) ;
1354+ action . AddBinding ( "<Gamepad>/buttonSouth" , processors : "invert" ) ;
1355+ action . AddBinding ( "<Keyboard>/space" , interactions : "tap" ) ;
1356+
1357+ // Check that the effective paths are correct
1358+ Assert . That ( action . bindings [ 0 ] . effectivePath , Is . EqualTo ( "<Gamepad>/buttonSouth" ) ) ;
1359+ Assert . That ( action . bindings [ 0 ] . effectiveInteractions , Is . EqualTo ( null ) ) ;
1360+ Assert . That ( action . bindings [ 0 ] . effectiveProcessors , Is . EqualTo ( "invert" ) ) ;
1361+
1362+ Assert . That ( action . bindings [ 1 ] . effectivePath , Is . EqualTo ( "<Keyboard>/space" ) ) ;
1363+ Assert . That ( action . bindings [ 1 ] . effectiveInteractions , Is . EqualTo ( "tap" ) ) ;
1364+ Assert . That ( action . bindings [ 1 ] . effectiveProcessors , Is . EqualTo ( null ) ) ;
1365+
1366+ action . ApplyBindingOverride ( 0 , "<Gamepad>/buttonWest" ) ;
1367+ action . ApplyBindingOverride ( 1 , new InputBinding
1368+ {
1369+ overridePath = "<Keyboard>/a" ,
1370+ overrideInteractions = "" ,
1371+ overrideProcessors = "multiply" ,
1372+ } ) ;
1373+
1374+ var actionRebindsJson = action . SaveBindingOverridesAsJson ( ) ;
1375+ Debug . Log ( actionRebindsJson . ToString ( ) ) ;
1376+
1377+ action . LoadBindingOverridesFromJson ( actionRebindsJson ) ;
1378+
1379+ // Check that effective binding path changed
1380+ Assert . That ( action . bindings [ 0 ] . effectivePath , Is . EqualTo ( "<Gamepad>/buttonWest" ) ) ;
1381+ Assert . That ( action . bindings [ 0 ] . overridePath , Is . EqualTo ( "<Gamepad>/buttonWest" ) ) ;
1382+ Assert . That ( action . bindings [ 0 ] . path , Is . EqualTo ( "<Gamepad>/buttonSouth" ) ) ;
1383+ // Check that effective interaction maintained it's null value
1384+ Assert . That ( action . bindings [ 0 ] . effectiveInteractions , Is . EqualTo ( null ) ) ;
1385+ Assert . That ( action . bindings [ 0 ] . overrideInteractions , Is . EqualTo ( null ) ) ;
1386+ Assert . That ( action . bindings [ 0 ] . interactions , Is . EqualTo ( null ) ) ;
1387+ // Check that effective interaction maintained it's previously set value
1388+ Assert . That ( action . bindings [ 0 ] . effectiveProcessors , Is . EqualTo ( "invert" ) ) ;
1389+ Assert . That ( action . bindings [ 0 ] . overrideProcessors , Is . EqualTo ( null ) ) ;
1390+ Assert . That ( action . bindings [ 0 ] . processors , Is . EqualTo ( "invert" ) ) ;
1391+
1392+ // Check that effective binding path changed
1393+ Assert . That ( action . bindings [ 1 ] . effectivePath , Is . EqualTo ( "<Keyboard>/a" ) ) ;
1394+ Assert . That ( action . bindings [ 1 ] . overridePath , Is . EqualTo ( "<Keyboard>/a" ) ) ;
1395+ Assert . That ( action . bindings [ 1 ] . path , Is . EqualTo ( "<Keyboard>/space" ) ) ;
1396+ // Check that effective binding was disabled
1397+ Assert . That ( action . bindings [ 1 ] . effectiveInteractions , Is . EqualTo ( "" ) ) ;
1398+ Assert . That ( action . bindings [ 1 ] . overrideInteractions , Is . EqualTo ( "" ) ) ;
1399+ Assert . That ( action . bindings [ 1 ] . interactions , Is . EqualTo ( "tap" ) ) ;
1400+ // Check that effective binding which was null before, now has changed
1401+ Assert . That ( action . bindings [ 1 ] . effectiveProcessors , Is . EqualTo ( "multiply" ) ) ;
1402+ Assert . That ( action . bindings [ 1 ] . overrideProcessors , Is . EqualTo ( "multiply" ) ) ;
1403+ Assert . That ( action . bindings [ 1 ] . processors , Is . EqualTo ( null ) ) ;
1404+ }
1405+
13491406 [ Test ]
13501407 [ Category ( "Actions" ) ]
13511408 public void Actions_ActionMapFindBinding_ShouldReturnNegativeOne_IfEmpty ( )
0 commit comments