docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Use an existing input device to create a layout

    To use one of the existing C# InputDevice classes in code to interface with a device, you can build on an existing layout using JSON:

    
       {
            "name" : "MyDevice",
            "extend" : "Gamepad", // Or some other thing
            "controls" : [
                {
                    "name" : "firstButton",
                    "layout" : "Button",
                    "offset" : 0,
                    "bit": 0,
                    "format" : "BIT",
                },
                {
                    "name" : "secondButton",
                    "layout" : "Button",
                    "offset" : 0,
                    "bit": 1,
                    "format" : "BIT",
                },
                {
                    "name" : "axis",
                    "layout" : "Axis",
                    "offset" : 4,
                    "format" : "FLT",
                    "parameters" : "clamp=true,clampMin=0,clampMax=1"
                }
            ]
        }
    
    

    You then register your layout with the system and then instantiate it:

    
       InputSystem.RegisterControlLayout(myDeviceJson);
        var device = InputSystem.AddDevice("MyDevice");
    
    
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)