{"id":13677465,"url":"https://github.com/RyanNielson/InputBinder","last_synced_at":"2025-04-29T11:30:53.130Z","repository":{"id":32807157,"uuid":"36399743","full_name":"RyanNielson/InputBinder","owner":"RyanNielson","description":"Easily bind input events to methods in Unity.","archived":false,"fork":false,"pushed_at":"2015-05-28T22:20:46.000Z","size":164,"stargazers_count":76,"open_issues_count":2,"forks_count":13,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-07T17:42:05.706Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RyanNielson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-27T22:30:42.000Z","updated_at":"2025-01-21T09:51:50.000Z","dependencies_parsed_at":"2022-09-12T14:12:40.756Z","dependency_job_id":null,"html_url":"https://github.com/RyanNielson/InputBinder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyanNielson%2FInputBinder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyanNielson%2FInputBinder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyanNielson%2FInputBinder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyanNielson%2FInputBinder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RyanNielson","download_url":"https://codeload.github.com/RyanNielson/InputBinder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251493728,"owners_count":21598156,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T13:00:42.663Z","updated_at":"2025-04-29T11:30:52.807Z","avatar_url":"https://github.com/RyanNielson.png","language":"C#","readme":"# InputBinder\n\nInputBinder makes it easy for components to respond to axis, button, and key input events. Bind game inputs to methods via code or using the inspector to add event driven input handling to your project.\n\nThis is somewhat based on Unreal Engine 4's [InputComponent](https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Components/UInputComponent/index.html).\n\n## Methods\n```cs \nBindAxis(string name, UnityAction\u003cfloat\u003e action)\n```\nBinds an given axis name to a method that has a single float argument. This method will be called every `Update` with the value of the axis.\n\n```cs \nBindButton(string name, InputEvent inputEvent, UnityAction action)\n```\nBinds an given button name and `InputEvent` type to a method that has no arguments. This method will only be called when the provided input event occurs for the given input name.\n\n```cs \nBindKey(KeyCode key, InputEvent inputEvent, UnityAction action)\n```\nBinds an given `KeyCode` and `InputEvent` type to a method that has no arguments. This method will only be called when the provided input event occurs for the given key.\n\n## Usage\n\nTo begin using InputBinder you need to add the InputBinder component to a GameObject. Once added, the inspector allows you to bind input via the inspector using UnityEvents, or you can create bindings in code. Both methods will be explained, and assume you're working with a GameObject with an InputBinder component.\n\n### Via Scripts\n\n```cs\nusing UnityEngine;\nusing System.Collections;\nusing RyanNielson.InputBinder;\n\npublic class InputBinderTester : MonoBehaviour \n{\n    InputBinder inputBinder;\n\n    void Start () \n    {\n        inputBinder = GetComponent\u003cInputBinder\u003e();\n\n        inputBinder.BindAxis(\"Horizontal\", Horizontal);\n        inputBinder.BindAxis(\"Vertical\", Vertical);\n\n        inputBinder.BindButton(\"Jump\", InputEvent.Pressed, JumpPressed);\n        inputBinder.BindButton(\"Jump\", InputEvent.Released, JumpReleased);\n        inputBinder.BindButton(\"Jump\", InputEvent.Held, JumpHeld);\n        \n        inputBinder.BindButton(KeyCode.Space, InputEvent.Pressed, JumpPressed);\n        inputBinder.BindButton(KeyCode.Space, InputEvent.Released, JumpReleased);\n        inputBinder.BindButton(KeyCode.Space, InputEvent.Held, JumpHeld);\n    }\n\t\n    public void Horizontal(float value)\n    {\n        // Use Horizontal axis value here.\n    }\n\n    public void Vertical(float value)\n    {\n        // Use Vertical axis value here.\n    }\n\n    public void JumpPressed()\n    {\n       \t// Respond to Jump or space key input pressed.\n    }\n\n    public void JumpReleased()\n    {\n        // Respond to Jump or space key input released.\n    }\n\n    public void JumpHeld()\n    {\n        // Respond to Jump or space key input held.\n    }\n}\n```\n\n## Via Inspector\n\nUsing InputBinder via the inspector makes it quite easy to set up input bindings. All that is required is to add an element to either the Axis Bindings, Button Bindings, or Key Bindings list. Once added, each type of binding has its own options.\n\n#### Axis Bindings\n\nSelect the axis name that was set up in Unity's input manager, and then use the Bound Event selector to choose objects and methods to bind to the axis. The chosen methods must accept a single float argument.\n\n#### Button Bindings\n\nSelect the button name that was set up in Unity's input manager, input event, and then use the Bound Event selector to choose objects and methods to bind to the button.\n\n##### Key Bindings\n\nSelect the key, input event, and then use the Bound Event selector to choose objects and methods to bind to the button.\n","funding_links":[],"categories":["Open Source Repositories","Controller","Open Source Packages","Input"],"sub_categories":["Input"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRyanNielson%2FInputBinder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRyanNielson%2FInputBinder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRyanNielson%2FInputBinder/lists"}