docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Introduction to on-screen controls

    You can use on-screen controls to simulate Input Devices with UI widgets that the user interacts with on the screen. The most prominent example is the use of stick and button widgets on touchscreens to emulate a joystick or gamepad.

    There are two built-in on-screen control types:

    • On-screen buttons
    • On-screen sticks

    You can implement custom controls by extending the base OnScreenControl class (see documentation on writing custom on screen controls to learn more).

    Note

    On-screen controls don't have a predefined visual representation. It's up to you to set up the visual aspect of a control (for example, by adding a sprite or UI component to the GameObject). On-screen controls take care of the interaction logic and of setting up and generating input from interactions.

    Each on-screen control uses a control path to reference the control that it should report input as. For example, the following on-screen button reports input as the right shoulder button of a gamepad:

    The OnScreenButton component displays the Control Path value as rightShoulder [Gamepad].

    The collection of on-screen controls present in a Scene forms one or more input devices. The Input System creates one input Device for each distinct type of device the controls reference. For example, if one on-screen button references <Gamepad>/buttonSouth and another on-screen button references <Keyboard>/a, the Input System creates both a Gamepad and a Keyboard. This happens automatically when the components are enabled. When disabled, the Input System automatically removes the devices again.

    To query the control (and, implicitly, the device) that an on-screen control feeds into, you can use the OnScreenControl.control property.

    Note

    This design allows you to use on-screen controls to create input for arbitrary input devices, in addition to joysticks and gamepads.

    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)