- Home /
PlayerInput.actions.ToJson() doesn't make a json-readable string
I am implementing key-binding with the new system and I am now trying to pass the overrides to a json to save and load so that the bindings persist while restarting the application. But the json is missing a huge chunk of information.
public void Save()
{
string path = "Assets/Resources/JsonData/InputData.json";
FileStream stream = new FileStream(path, FileMode.Create);
StreamWriter writer = new StreamWriter(stream);
writer.Write(playerInput.actions.ToJson());
}
The Json reads:
{
"name": "Input",
"maps": [
{
"name": "Player",
"id": "63f13d68-45ee-4995-a484-fa5d5ebeb830",
"actions": [
{
"name": "Move",
"type": "Value",
"id": "0a9bb7a4-516b-440b-91bb-3429fe0567be",
"expectedControlType": "Button",
"processors": "",
"interactions": ""
},
{
"name": "Look",
"type": "PassThrough",
"id": "a569b792-66b7-4084-b61b-33996b836240",
"expectedControlType": "Vector2",
"processors": "",
"interactions": ""
},
{
"name": "Jump",
"type": "Value",
"id": "a1f19c0c-ce90-4f16-bbef-f7c3f5474f17",
"expectedControlType": "",
"processors": "",
"interactions": ""
},
{
"name": "Crouch",
"type": "Button",
"id": "f6738232-03b2-4316-8784-11279c0889ae",
"expectedControlType": "Button",
"processors": "",
"interactions": ""
},
{
"name": "Fire",
"type": "Button",
"id": "4d6d56c9-fbaa-408c-894b-578542f3bc72",
"expectedControlType": "Button",
"processors": "",
"interactions": ""
}
],
"bindings": [
{
"name": "1D Axis",
"id": "f806ab96-fe65-4862-a809-e6b6ae3682f4",
"path": "1DAxis",
"interactions": "",
"processors": "",
"groups": "",
"action": "Move",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "negative",
"id": "b01805d2-35a0-4e5a-9679-a5f849dde1e7",
"path": "<Keyboard>/a",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "positive",
"id": "0b82887e-2288-4334-bbaf-a09546a85b20",
"path": "<Keyboard>/d",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "1D Axis",
"id": "c9486996-af0c-4585-8fcd-1240837286a3",
"path": "1DAxis",
"interactions": "",
"processors": "",
"groups": "",
"action": "Move",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "negative",
"id": "30887c52-becb-4fbb-9f88-eb343de1d413",
"path": "<Gamepad>/leftStick/left",
"interactions": "",
"processors": "",
"groups": "Gamepad",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "positive",
"id": "f817a209-831c-4e02-8ff3-e805e875fb5c",
"path": "<Gamepad>/leftStick/right",
"interactions": "",
"processors": "",
"groups": "Gamepad",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "",
"id": "fd98d215-2f42-4b9b-bcd7-7f6ad317c425",
"path": "<Mouse>/position",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Look",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "56952afb-30af-462d-a7cb-467f31323b43",
"path": "<Gamepad>/rightStick",
"interactions": "",
"processors": "",
"groups": "Gamepad",
"action": "Look",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "33b36221-890e-444c-9fc3-d0f6111de689",
"path": "<Keyboard>/w",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Jump",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "56881a02-8f50-470a-904d-768f1228bd6c",
"path": "<Gamepad>/buttonSouth",
"interactions": "",
"processors": "",
"groups": "Gamepad",
"action": "Jump",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "6c5e142c-f53e-423b-a29c-43101e29a3d9",
"path": "<Keyboard>/s",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Crouch",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "e1f23c2c-976d-4b06-8327-c45a703f7bb1",
"path": "<Gamepad>/leftStick/down",
"interactions": "",
"processors": "",
"groups": "Gamepad",
"action": "Crouch",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "92c715ae-da33-4255-983e-969881c8427c",
"path": "<Mouse>/leftButton",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Fire",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "e1023fcd-5a94-4d7d-89d7-d6fca90776c0",
"path": "<Gamepad>/rightTrigger",
"interactions": "",
"processors": "",
"groups": "Gamepad",
"action": "Fire",
"isComposite": false,
"isPartOfComposite": false
}
]
},
{
"name": "UI",
"id": "dd586960-d601-41c3-9283-25728326f938",
"actions": [
{
"name": "Navigate",
"type": "Value",
"id": "917a5166-713d-4ebc-9a31-479f2af018eb",
"expectedControlType": "Vector2",
"processors": "",
"interactions": ""
},
{
"name": "Submit",
"type": "Button",
"id": "e19f9689-b3e1-4520-8532-fad3337ea5da",
"expectedControlType": "Button",
"processors": "",
"interactions": ""
},
{
"name": "Cancel",
"type": "Button",
"id": "61af901d-c6d2-4f3b-9df8-7acb2bcc15f7",
"expectedControlType": "Button",
"processors": "",
"interactions": ""
},
{
"name": "Point",
"type": "PassThrough",
"id": "fead1745-f8e9-457a-b06c-1f3f9f823d2d",
"expectedControlType": "Vector2",
"processors": "",
"interactions": ""
},
{
"name": "Click",
"type": "PassThrough",
"id": "14f25a95-7ebc-4841-81ad-7882421f4de1",
"expectedControlType": "Button",
"processors": "",
"interactions": ""
},
{
"name": "ScrollWheel",
"type": "PassThrough",
"id": "1bf954e4-62c3-44d4-ac71-6d01ab0d29d5",
"expectedControlType": "Vector2",
"processors": "",
"interactions": ""
},
{
"name": "MiddleClick",
"type": "PassThrough",
"id": "7f087c51-3711-48da-bc01-71ca8cea616c",
"expectedControlType": "",
"processors": "",
"interactions": ""
},
{
"name": "RightClick",
"type": "PassThrough",
"id": "70fd8308-2dac-4cc7-bba4-70d3ffe7bfb8",
"expectedControlType": "",
"processors": "",
"interactions": ""
},
{
"name": "TrackedDevicePosition",
"type": "PassThrough",
"id": "93b55903-1ead-47d4-ac99-780a7dd373db",
"expectedControlType": "Vector3",
"processors": "",
"interactions": ""
},
{
"name": "TrackedDeviceOrientation",
"type": "PassThrough",
"id": "4bfa96c2-6c3e-4a54-9808-da56b212bbe8",
"expectedControlType": "Quaternion",
"processors": "",
"interactions": ""
},
{
"name": "Open wheel",
"type": "Button",
"id": "e5a17fbe-2ede-463d-980c-14bb6f2b3c71",
"expectedControlType": "Button",
"processors": "",
"interactions": ""
},
{
"name": "Open Main",
"type": "Button",
"id": "a98123de-1618-40bc-944e-fb043b44043d",
"expectedControlType": "Button",
"processors": "",
"interactions": ""
},
{
"name": "Navigate Element Wheel",
"type": "PassThrough",
"id": "f8a1fd82-da3e-4289-b056-2a933dcf1178",
"expectedControlType": "Vector2",
"processors": "",
"interactions": ""
}
],
"bindings": [
{
"name": "Gamepad",
"id": "809f371f-c5e2-4e7a-83a1-d867598f40dd",
"path": "2DVector",
"interactions": "",
"processors": "",
"groups": "",
"action": "Navigate",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "up",
"id": "14a5d6e8-4aaf-4119-a9ef-34b8c2c548bf",
"path": "<Gamepad>/leftStick/up",
"interactions": "",
"processors": "",
"groups": ";Gamepad",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "up",
"id": "9144cbe6-05e1-4687-a6d7-24f99d23dd81",
"path": "<Gamepad>/rightStick/up",
"interactions": "",
"processors": "",
"groups": ";Gamepad",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "down",
"id": "2db08d65-c5fb-421b-983f-c71163608d67",
"path": "<Gamepad>/leftStick/down",
"interactions": "",
"processors": "",
"groups": ";Gamepad",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "down",
"id": "58748904-2ea9-4a80-8579-b500e6a76df8",
"path": "<Gamepad>/rightStick/down",
"interactions": "",
"processors": "",
"groups": ";Gamepad",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "left",
"id": "8ba04515-75aa-45de-966d-393d9bbd1c14",
"path": "<Gamepad>/leftStick/left",
"interactions": "",
"processors": "",
"groups": ";Gamepad",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "left",
"id": "712e721c-bdfb-4b23-a86c-a0d9fcfea921",
"path": "<Gamepad>/rightStick/left",
"interactions": "",
"processors": "",
"groups": ";Gamepad",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "right",
"id": "fcd248ae-a788-4676-a12e-f4d81205600b",
"path": "<Gamepad>/leftStick/right",
"interactions": "",
"processors": "",
"groups": ";Gamepad",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "right",
"id": "1f04d9bc-c50b-41a1-bfcc-afb75475ec20",
"path": "<Gamepad>/rightStick/right",
"interactions": "",
"processors": "",
"groups": ";Gamepad",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "",
"id": "fb8277d4-c5cd-4663-9dc7-ee3f0b506d90",
"path": "<Gamepad>/dpad",
"interactions": "",
"processors": "",
"groups": ";Gamepad",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "Joystick",
"id": "e25d9774-381c-4a61-b47c-7b6b299ad9f9",
"path": "2DVector",
"interactions": "",
"processors": "",
"groups": "",
"action": "Navigate",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "up",
"id": "3db53b26-6601-41be-9887-63ac74e79d19",
"path": "<Joystick>/stick/up",
"interactions": "",
"processors": "",
"groups": "Joystick",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "down",
"id": "0cb3e13e-3d90-4178-8ae6-d9c5501d653f",
"path": "<Joystick>/stick/down",
"interactions": "",
"processors": "",
"groups": "Joystick",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "left",
"id": "0392d399-f6dd-4c82-8062-c1e9c0d34835",
"path": "<Joystick>/stick/left",
"interactions": "",
"processors": "",
"groups": "Joystick",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "right",
"id": "942a66d9-d42f-43d6-8d70-ecb4ba5363bc",
"path": "<Joystick>/stick/right",
"interactions": "",
"processors": "",
"groups": "Joystick",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "Keyboard",
"id": "ff527021-f211-4c02-933e-5976594c46ed",
"path": "2DVector",
"interactions": "",
"processors": "",
"groups": "",
"action": "Navigate",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "up",
"id": "563fbfdd-0f09-408d-aa75-8642c4f08ef0",
"path": "<Keyboard>/w",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "up",
"id": "eb480147-c587-4a33-85ed-eb0ab9942c43",
"path": "<Keyboard>/upArrow",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "down",
"id": "2bf42165-60bc-42ca-8072-8c13ab40239b",
"path": "<Keyboard>/s",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "down",
"id": "85d264ad-e0a0-4565-b7ff-1a37edde51ac",
"path": "<Keyboard>/downArrow",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "left",
"id": "74214943-c580-44e4-98eb-ad7eebe17902",
"path": "<Keyboard>/a",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "left",
"id": "cea9b045-a000-445b-95b8-0c171af70a3b",
"path": "<Keyboard>/leftArrow",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "right",
"id": "8607c725-d935-4808-84b1-8354e29bab63",
"path": "<Keyboard>/d",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "right",
"id": "4cda81dc-9edd-4e03-9d7c-a71a14345d0b",
"path": "<Keyboard>/rightArrow",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Navigate",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "",
"id": "9e92bb26-7e3b-4ec4-b06b-3c8f8e498ddc",
"path": "*/{Submit}",
"interactions": "",
"processors": "",
"groups": "",
"action": "Submit",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "6f6314d7-35f2-4656-97a3-411f5a4e8c0e",
"path": "<Gamepad>/rightStickPress",
"interactions": "",
"processors": "",
"groups": "",
"action": "Submit",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "82627dcc-3b13-4ba9-841d-e4b746d6553e",
"path": "*/{Cancel}",
"interactions": "",
"processors": "",
"groups": "",
"action": "Cancel",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "c52c8e0b-8179-41d3-b8a1-d149033bbe86",
"path": "<Mouse>/position",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Point",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "e1394cbc-336e-44ce-9ea8-6007ed6193f7",
"path": "<Pen>/position",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Point",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "5693e57a-238a-46ed-b5ae-e64e6e574302",
"path": "<Touchscreen>/touch*/position",
"interactions": "",
"processors": "",
"groups": "Touch",
"action": "Point",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "4faf7dc9-b979-4210-aa8c-e808e1ef89f5",
"path": "<Mouse>/leftButton",
"interactions": "",
"processors": "",
"groups": ";Keyboard&Mouse",
"action": "Click",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "8d66d5ba-88d7-48e6-b1cd-198bbfef7ace",
"path": "<Pen>/tip",
"interactions": "",
"processors": "",
"groups": ";Keyboard&Mouse",
"action": "Click",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "47c2a644-3ebc-4dae-a106-589b7ca75b59",
"path": "<Touchscreen>/touch*/press",
"interactions": "",
"processors": "",
"groups": "Touch",
"action": "Click",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "bb9e6b34-44bf-4381-ac63-5aa15d19f677",
"path": "<XRController>/trigger",
"interactions": "",
"processors": "",
"groups": "XR",
"action": "Click",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "38c99815-14ea-4617-8627-164d27641299",
"path": "<Mouse>/scroll",
"interactions": "",
"processors": "",
"groups": ";Keyboard&Mouse",
"action": "ScrollWheel",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "24066f69-da47-44f3-a07e-0015fb02eb2e",
"path": "<Mouse>/middleButton",
"interactions": "",
"processors": "",
"groups": ";Keyboard&Mouse",
"action": "MiddleClick",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "4c191405-5738-4d4b-a523-c6a301dbf754",
"path": "<Mouse>/rightButton",
"interactions": "",
"processors": "",
"groups": ";Keyboard&Mouse",
"action": "RightClick",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "7236c0d9-6ca3-47cf-a6ee-a97f5b59ea77",
"path": "<XRController>/devicePosition",
"interactions": "",
"processors": "",
"groups": "XR",
"action": "TrackedDevicePosition",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "23e01e3a-f935-4948-8d8b-9bcac77714fb",
"path": "<XRController>/deviceRotation",
"interactions": "",
"processors": "",
"groups": "XR",
"action": "TrackedDeviceOrientation",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "683d1ef6-4c0e-4e40-b673-45c4c8ecb6cd",
"path": "<Keyboard>/tab",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Open wheel",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "33e317a5-8941-465f-a2ca-c01f491bc2d9",
"path": "<Gamepad>/buttonNorth",
"interactions": "",
"processors": "",
"groups": "Gamepad",
"action": "Open wheel",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "75faa47c-f164-4603-ad02-9b72fe6b6507",
"path": "<Keyboard>/escape",
"interactions": "",
"processors": "",
"groups": "Keyboard&Mouse",
"action": "Open Main",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "5a60ebe5-6a0c-4843-8c00-8d6085fdb952",
"path": "<Gamepad>/start",
"interactions": "",
"processors": "",
"groups": "",
"action": "Open Main",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "4030a61e-13e0-46ae-b544-a1214d0a7d3a",
"path": "<Gamepad>/leftStick",
"interactions": "",
"processors": "",
"groups": "Gamepad",
"action": "Navigate Element Wheel",
"isComposite": false,
"isPartOfComposite": false
}
]
}
],
"controlSchemes": [
{
"name": "Keyboard&Mouse",
"bindingGroup": "Keyboard&Mouse",
"devices": [
{
"devicePath": "<Keyboard>",
"isOptional": false,
"isOR": false
},
{
"devicePath": "<Mouse>",
"isOptional": false,
"isOR": false
}
]
},
{
"name": "Gamepad",
"bindingGroup": "Gamepad",
"devices": [
{
"devicePath": "<Gamepad>",
"isOptional": false,
"isOR": false
}
]
},
{
"name": "Touch",
"bindingGroup": "Touch",
"devices": [
{
"devicePath": "<Touchscreen>",
"isOptional": false,
"isOR": false
}
]
},
{
"name": "Joystick",
"bindingGroup": "Joystick",
"devices": [
{
"devicePath": "<Joystick>",
"isOptional": false,
The Json does not end properly. Almost as though it is hitting a character cap. Though I tried putting single actionMaps through and the same problem occurred.
Another problem is that the json doesn't include the overridden bindings. It only shows the originals. An odd thing is, when I debug it gives the updated key bind.
Debug.Log(playerInput.actions.FindAction("Jump").GetBindingDisplayString());
My question is if this is a problem on my side or the API's? (The save method is called publicly by an apply button.) Please let me know if any more information is needed to provide an answer.