Skip to content
Skills Library
Programming · Building & coding

unity-input-ui

/unity-input-ui

Unity new Input System and UI — InputAction, InputActionAsset, PlayerInput, rebinding, multi-device, plus UI Toolkit (UXML/USS, runtime + editor) and uGUI Canvas optimization. USE WHEN: wiring input bindings, supporting gamepads/keyboard/touch, building menus/HUD with UI Toolkit or uGUI, optimizing Canvas batches, runtime rebinding, on-screen control overlays. DO NOT USE FOR: legacy `Input.GetKey` API (deprecated — migrate to new Input System); 3D world-space UI specifics (use `unity-rendering`).

Licence
MIT
Last repository change
21.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
1
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 21.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What to check before installing
  • SKILL.md zawiera komentarze HTML (1). Nie widać ich w podglądzie Markdown, a model je czyta.

What it does and when to use it

Unity new Input System and UI — InputAction, InputActionAsset, PlayerInput, rebinding, multi-device, plus UI Toolkit (UXML/USS, runtime + editor) and uGUI Canvas optimization. USE WHEN: wiring input bindings, supporting gamepads/keyboard/touch, building menus/HUD with UI Toolkit or uGUI, optimizing Canvas batches, runtime rebinding, on-screen control overlays. DO NOT USE FOR: legacy `Input.GetKey` API (deprecated — migrate to new Input System); 3D world-space UI specifics (use `unity-rendering`).

Original author description

Unity new Input System and UI — InputAction, InputActionAsset, PlayerInput, rebinding, multi-device, plus UI Toolkit (UXML/USS, runtime + editor) and uGUI Canvas optimization. USE WHEN: wiring input bindings, supporting gamepads/keyboard/touch, building menus/HUD with UI Toolkit or uGUI, optimizing Canvas batches, runtime rebinding, on-screen control overlays. DO NOT USE FOR: legacy `Input.GetKey` API (deprecated — migrate to new Input System); 3D world-space UI specifics (use `unity-rendering`).

How it works

  1. New Input System — basics
  2. Action types
  3. Composite bindings (WASD + arrows + stick)
  4. Runtime rebinding
  5. On-screen controls
  6. UI Toolkit (UXML/USS)
  7. uGUI optimization (when you must use uGUI)
  8. Anti-patterns
  9. Production checklist
Original SKILL.md headings · 133 lines, 532 words
SKILL.md preview
---
name: unity-input-ui
description: |
  Unity new Input System and UI — InputAction, InputActionAsset, PlayerInput,
  rebinding, multi-device, plus UI Toolkit (UXML/USS, runtime + editor) and
  uGUI Canvas optimization.

  USE WHEN: wiring input bindings, supporting gamepads/keyboard/touch, building
  menus/HUD with UI Toolkit or uGUI, optimizing Canvas batches, runtime
  rebinding, on-screen control overlays.

  DO NOT USE FOR: legacy `Input.GetKey` API (deprecated — migrate to new Input
  System); 3D world-space UI specifics (use `unity-rendering`).
allowed-tools: Read, Grep, Glob, Write, Edit
---

# Unity Input System & UI

## New Input System — basics

```csharp
public class PlayerInput : MonoBehaviour {
    [SerializeField] private InputActionAsset inputActions;
    private InputAction _move, _jump, _attack;

    private void OnEnable() {
        var gameplay = inputActions.FindActionMap("Gameplay", true);
        gameplay.Enable();
        _move   = gameplay.FindAction("Move", true);
        _jump   = gameplay.FindAction("Jump", true);
        _attack = gameplay.FindAction("Attack", true);

        _jump.performed   += OnJump;
        _attack.performed += OnAttack;
    }

    private void OnDisable() {
        _jump.performed   -= OnJump;
        _attack.performed -= OnAttack;
    }

    private void Update() {
        Vector2 dir = _move.ReadValue<Vector2>();
        // movement using dir
    }

    private void OnJump(InputAction.CallbackContext ctx)   => /* jump */;
    private void OnAttack(InputAction.CallbackContext ctx) => /* attack */;
}
```

`PlayerInput` component variant: use when designer wants a UI to wire callbacks; manual binding (above) is better for systems code.

## Action types

- **Button** — pressed/released; works for any binding kind.
- **Value** — continuous (e.g. stick).
- **PassThrough** — unfiltered, for raw streams (gestures).

## Composite bindings (WASD + arrows + stick)

In InputActionAsset: action `Move` (Value/Vector2), 2D Vector composite with W/A/S/D + arrows; second binding from `<Gamepad>/leftStick`.

## Runtime rebinding

```csharp
var rebind = action.PerformInteractiveRebindingOperation()
    .WithControlsExcluding("<Mouse>/position")
    .WithCancelingThrough("<Keyboard>/escape")
    .OnComplete(op => {
        op.Dispose();
        SaveBindings(inputActions);
    })
    .Start();
```

Save with `inputActions.SaveBindingOverridesAsJson()` → PlayerPrefs/file. Load on startup with `LoadBindingOverridesFromJson(json)`.

## On-screen controls

Use the Input System's `On-Screen Button`/`On-Screen Stick` components on UI elements; they emit input through the same action — no separate touch path.

## UI Toolkit (UXML/USS)

```xml
<!-- HUD.uxml -->
<ui:UXML xmlns:ui="UnityEngine.UIElements">
  <ui:VisualElement class="hud-root">
    <ui:Label name="health" class="hud-label" text="HP: 100" />
    <ui:ProgressBar name="hpBar" low-value="0" high-value="100" value="100" />
  </ui:VisualElement>
</ui:UXML>
```

```css
/* HUD.uss */
.hud-root { position: absolute; top: 16px; left: 16px; }
.hud-label { color: white; font-size: 18px; -unity-font-style: bold; }
```

```csharp
public class HUD : MonoBehaviour {
    [SerializeField] private UIDocument doc;
    private Label _health;
    private ProgressBar _hpBar;

    private void OnEnable() {
        var root = doc.rootVisualElement;
        _health = root.Q<Label>("health");
        _hpBar  = root.Q<ProgressBar>("hpBar");
    }

    public void SetHealth(int hp) {
        _health.text  = $"HP: {hp}";
        _hpBar.value  = hp;
    }
}
```

UI Toolkit is the default for new in-game UI in Unity 6 — better batching, retained-mode tree, USS hot reload.

## uGUI optimization (when you must use uGUI)

| Issue | Fix |
|---|---|
| Whole canvas redraws on any change | Split canvas: static elements on one, dynamic on another |
| Many `Image` with different sprites | Sprite Atlas v2 → identical material → batched |
| Per-frame `text.text = …` | Only assign when value actually changes |
| `LayoutGroup` rebuilds | Cache results; prefer fixed sizes when possible |

## Anti-patterns

| Anti-pattern | Fix |
|---|---|
| `Input.GetKey` legacy API | Use new Input System actions |
| Polling `_jump.WasPressedThisFrame()` everywhere | Subscribe to `.performed` events once |
| One huge canvas with HUD + menus | Multiple canvases; only the one being interacted redraws |
| `GameObject.Find("HpBar")` | `[SerializeField]` reference or `UIDocument.rootVisualElement.Q` |

## Production checklist

- [ ] InputActionAsset committed; bindings cover keyboard + gamepad + touch
- [ ] Rebinding UI persists overrides
- [ ] UI Toolkit used for new UI; uGUI only for legacy reasons
- [ ] All sprites in Sprite Atlases
- [ ] Canvas split static vs dynamic
- [ ] EventSystem present and configured for chosen UI module

Versions

The database has no other skills named unity-input-ui.

Database snapshot: 13.11.2026 · package version 0e618cea2882 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100unity-ui
    Unity 6 UI development guide. Use when building user interfaces, menus, HUD, buttons, or any UI elements. Covers UI Toolkit (recommended for new projects — USS, UXML, UI Builder, data binding), uGUI/Canvas (legacy runtime UI), and IMGUI. Based on Unity 6.3 LTS documentation.
  • 100scenario-unity-ui
    Use when building or fixing game UI in Unity 6.3: main menu, settings screen (resolution, quality, volume, key rebinding), HUD, health bar, minimap frame; choosing uGUI or UI Toolkit or mixing both; 'UI scales wrong on phones', portrait to 4K, Canvas Scaler, anchors, layout…
  • 100unity-input-system
    Wire player input in Unity 6.3 LTS with the Input System package: Input Actions, action maps, the PlayerInput component, and reading values via callbacks or polling. Use when the project has a .inputactions asset or com.unity.inputsystem, or when the user mentions the Unity…
  • 100unity-input-system
    Wire player input in Unity 6.3 LTS with the Input System package: Input Actions, action maps, the PlayerInput component, and reading values via callbacks or polling. Use when the project has a .inputactions asset or com.unity.inputsystem, or when the user mentions the Unity…
  • 100unity-game-dev
    Use when working on Unity game projects, especially Unity 6, C# gameplay systems, UI Toolkit or UGUI, Addressables, Input System, UniTask, Onity, ServiceLocator, tests, performance, project structure, package setup, and Unity-specific architecture decisions.
  • 100unity-input
    Unity 6 Input System guide. Use when handling player input, controls, gamepad, keyboard, mouse, touch, or XR controllers. Covers the new Input System package (recommended), Input Actions, Action Maps, Control Schemes, PlayerInput component, and input debugging. Based on Unity 6.3 LTS documentation.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.