{"id":649,"date":"2024-01-15T19:23:34","date_gmt":"2024-01-16T03:23:34","guid":{"rendered":"https:\/\/downthecrop.xyz\/blog\/?p=649"},"modified":"2024-01-15T19:23:34","modified_gmt":"2024-01-16T03:23:34","slug":"unity-control-schemes-no-events-firing","status":"publish","type":"post","link":"https:\/\/downthecrop.xyz\/blog\/unity-control-schemes-no-events-firing\/","title":{"rendered":"Unity Control Schemes &#8211; No Events Firing"},"content":{"rendered":"<p>I ran into a problem when working with the action map in my Unity game. I wanted to break the controls into their own separate schemes for rebinding, but there was a problem! When I added the control schemes, my code seemed to stop working. I checked the C# callback and Default Map on my PlayerInput component, toggling autoswitch didn't do anything, and I double-checked to make sure there were no other scripts consuming the input events.<\/p>\n<p>After inspecting the InputAsset as JSON, I noticed something! The devices (although in the editor it says &quot;All Devices&quot;) were empty!<\/p>\n<pre><code>\"controlSchemes\": [\n    {\n        \"name\": \"Gamepad\",\n        \"bindingGroup\": \"Gamepad\",\n        \"devices\": []\n    },\n    {\n        \"name\": \"Keyboard\",\n        \"bindingGroup\": \"Keyboard\",\n        \"devices\": []\n    },\n    {\n        \"name\": \"GCC\",\n        \"bindingGroup\": \"GCC\",\n        \"devices\": []\n    }\n]<\/code><\/pre>\n<p>Aha! I remembered a little tick box I didn't know the use of when creating the control schemes!<br \/>\n<img src=\"https:\/\/i.imgur.com\/iimzht2.png\" alt=\"Image 1\" width=\"300\"\/> <img src=\"https:\/\/i.imgur.com\/8s6MOvK.png\" alt=\"Image 2\" width=\"300\"\/><\/p>\n<p>Here's what it looked like after I assigned them:<\/p>\n<pre><code>\"controlSchemes\": [\n    {\n        \"name\": \"Gamepad\",\n        \"bindingGroup\": \"Gamepad\",\n        \"devices\": [\n            {\n                \"devicePath\": \"<Gamepad>\",\n                \"isOptional\": false,\n                \"isOR\": false\n            }\n        ]\n    },\n    {\n        \"name\": \"Keyboard\",\n        \"bindingGroup\": \"Keyboard\",\n        \"devices\": [\n            {\n                \"devicePath\": \"<Keyboard>\",\n                \"isOptional\": false,\n                \"isOR\": false\n            }\n        ]\n    },\n    {\n        \"name\": \"GCC\",\n        \"bindingGroup\": \"GCC\",\n        \"devices\": [\n            {\n                \"devicePath\": \"<HID::mayflash limited GameCube Controller Adapter>\",\n                \"isOptional\": false,\n                \"isOR\": false\n            }\n        ]\n    }\n]<\/code><\/pre>\n<p>So remember to assign the device (although you already assigned the buttons in the action map) to the scheme!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I ran into a problem when working with the action map in my Unity game. I wanted to break the controls into their own separate schemes for rebinding, but there was a problem! When I added the control schemes, my code seemed to stop working. I checked the C# callback and Default Map on my &hellip; <a href=\"https:\/\/downthecrop.xyz\/blog\/unity-control-schemes-no-events-firing\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Unity Control Schemes &#8211; No Events Firing<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"amp_validity":null,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/downthecrop.xyz\/blog\/wp-json\/wp\/v2\/posts\/649"}],"collection":[{"href":"https:\/\/downthecrop.xyz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/downthecrop.xyz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/downthecrop.xyz\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/downthecrop.xyz\/blog\/wp-json\/wp\/v2\/comments?post=649"}],"version-history":[{"count":1,"href":"https:\/\/downthecrop.xyz\/blog\/wp-json\/wp\/v2\/posts\/649\/revisions"}],"predecessor-version":[{"id":650,"href":"https:\/\/downthecrop.xyz\/blog\/wp-json\/wp\/v2\/posts\/649\/revisions\/650"}],"wp:attachment":[{"href":"https:\/\/downthecrop.xyz\/blog\/wp-json\/wp\/v2\/media?parent=649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/downthecrop.xyz\/blog\/wp-json\/wp\/v2\/categories?post=649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/downthecrop.xyz\/blog\/wp-json\/wp\/v2\/tags?post=649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}