Unity UI Toolkit Multi-Input Demo 3
Budget: $30 – $250 USD
Unity 3D 6.3.2 UI toolkit Multi-input demo 3
********************************************
Document version 2026-01-30
Unity 6.3.2 Demonstration of mode-less simultaneous mouse, keyboard and USB analog joystick control of player, world-space UI toolkit and screen-space UI toolkit.
Revision history
*******************
Compared to version 1 of this document, there are changes in sections 1.7, 2.3.4, 3.2, 3.10-3.14, 4.1 and 4.4
1 General Requirements
****************************
1.1 Windows PC
1.2 Unity 6.3.2 LTS HDRP
1.3 Input System using the “send messages” method of communication
1.4 UI Toolkit
1.5 The project has one outdoor scene.
1.6 All entities (including input and UI set-up etc) are to be generated procedurally from C# scripts.
1.7 Very neat, clean, robust and well-commented C# code
A C# implementation where the repetitive elements are reused and instantiated etc as to create ease of flexibility is preferred.
The goal here is the C# code itself, showing how to program this type of multiple-input UI in an elegant and efficient way, rather than how "sleek" the visuals look.
Thus, the robust stability, structure, clarity and readability of the code and the comments is what is important.
The objective is to have the Screen-space UI, World-space UI and First Person Character active at the same time, using input from keyboard, analog joystick and mouse.
All of these handling input at the same time.
This is intended as a demo and code example of mode-less user interaction.
Structurally this can be considered as similar to a two-player situation, where one player has the joystick and keyboard and controls the First Person Character, while the other player has the mouse and controls the Screen-space Ui and the World-space UI.
I´m open to any and all suggestions, ideas and changes that make the project better, more robust or easier to implement.
1.8 The deliverable is a Unity package.
1.9 It may be assumed that the joystick and keyboard are not used to move the player while the mouse is used to move the world-space plane or UI buttons, but the screen-space UI must be operational and responding to mouse input when the player is moving at the same time.
2 First person character
***************************
2.1 The scene has a 1st person camera with a character controller.
2.2 The player can be moved by keyboard keys W S A D and rotated with Q and E.
2.3 The player can also be moved on the plane by input from an analog multi-axis USB joystick, such as a Thrustmaster T Flight-stick X.
2.3.1 Joystick forward - backward moves the player forward at a speed proportional to the joystick position.
2.3.2 Joystick left-right moves the player sideways at a speed proportional to the joystick position.
2.3.3 Joystick twist left-right rotates the player at a rate proportional to the amount of joystick twist.
2.3.4 The WSAD keys add 100% translation velocity and the QE keys add 100% rotation speed to the character controller on top of whatever the 0-100% signal is from the joystick.
3 World-space UI
********************
3.1 There is a one plane of scale (1,1,1) located at (0,0,0) with rotation (0,0,0)
3.2 On this plane there is a world-space UI toolkit document with several world-space buttons labeled Button 1 to Button 10.
The world space UI elements should be in a local coordinate system of the plane, such that the UI elements (aka buttons) can follow the two most nearby edges of the plane when the plane is moved/stretched/rotated.
3.3 Each button can be clicked with the computer mouse, as well as moved around on the plane with the mouse click-hold-drag-release.
3.4 When clicked, dragged or released, there is a corresponding log message “Button 1 pressed”, “Button 1 dragged” or “Button 1 released”.
3.5 By left-clicking and dragging near the corner of a button it can be resized.
3.6 By right-clicking and dragging a corner of a button it can be rotated.
3.7 By the mouse scroll-wheel the button can be resized.
3.8 The plane can be resized by mouse left click-drag near the corners and edge (in locations where there are not buttons), as well as moved by click-drag of locations within the plane further from the edges where there also are no buttons.
3.9 The plane can be rotated by right-click and drag.
3.10 Combining the keyboard SHIFT key with mouse LEFT, mouse RIGHT or mouse SCROLL-WHEEL will constrain the corresponding mouse actions to a suitable grid snap.
3.11 The translation, scaling and rotation of the plane is constrained by how much the mouse can move, and also by where the First Person Character controller is in relation to the plane.
I don´t think there is a need for limits as such on the movements of the plane, however if it makes the implementation easier or more robust, it can be done with limits.
3.12 By long left-click near the center of a button the button will become selected for editing. This is indicated by a bright colour change of the button outline.
In the selected state the button can be moved by the keyboard UP, DOWN, LEFT and RIGHT keys.
3.13 At any time a maximum of one button can be in the selected state.
3.14 A selected button is deselected when any other button (in either world-space or screen-space) is selected, clicked, dragged or rotated.
4 Screen-space UI
**********************
4.1 In screen-space there is an UI toolkit document with several screen-space buttons labeled Button 11 to Button 20, placed along the edges of the game window.
The screen-space UI document is intended to cover the whole of the Game Window, and this UI document is intended to be transparent (both to graphics and to screen-space mouse actions) everywhere except where the screen-space buttons are.
4.2 If the Windows game window size changes, these buttons move accordingly, such that these buttons keep their locations relative to the screen window edges.
4.3 These buttons can be clicked, dragged, resized and rotated similar to the world-space buttons, and give similar log messages.
4.4 The screen-space buttons will visually (and for mouse-actions) "float on top of" whatever is in the view of the world-space.
If a screen-space button blocks the view of a world-space button, the screen-space button has priority, both visually and for mouse actions.
If a screen space UI element, such as a Button is being moved, resized or rotated by mouse actions, care must be taken not to erroneously interact with any world-space object such as a world-space button or plane.
********************************************
Document version 2026-01-30
Unity 6.3.2 Demonstration of mode-less simultaneous mouse, keyboard and USB analog joystick control of player, world-space UI toolkit and screen-space UI toolkit.
Revision history
*******************
Compared to version 1 of this document, there are changes in sections 1.7, 2.3.4, 3.2, 3.10-3.14, 4.1 and 4.4
1 General Requirements
****************************
1.1 Windows PC
1.2 Unity 6.3.2 LTS HDRP
1.3 Input System using the “send messages” method of communication
1.4 UI Toolkit
1.5 The project has one outdoor scene.
1.6 All entities (including input and UI set-up etc) are to be generated procedurally from C# scripts.
1.7 Very neat, clean, robust and well-commented C# code
A C# implementation where the repetitive elements are reused and instantiated etc as to create ease of flexibility is preferred.
The goal here is the C# code itself, showing how to program this type of multiple-input UI in an elegant and efficient way, rather than how "sleek" the visuals look.
Thus, the robust stability, structure, clarity and readability of the code and the comments is what is important.
The objective is to have the Screen-space UI, World-space UI and First Person Character active at the same time, using input from keyboard, analog joystick and mouse.
All of these handling input at the same time.
This is intended as a demo and code example of mode-less user interaction.
Structurally this can be considered as similar to a two-player situation, where one player has the joystick and keyboard and controls the First Person Character, while the other player has the mouse and controls the Screen-space Ui and the World-space UI.
I´m open to any and all suggestions, ideas and changes that make the project better, more robust or easier to implement.
1.8 The deliverable is a Unity package.
1.9 It may be assumed that the joystick and keyboard are not used to move the player while the mouse is used to move the world-space plane or UI buttons, but the screen-space UI must be operational and responding to mouse input when the player is moving at the same time.
2 First person character
***************************
2.1 The scene has a 1st person camera with a character controller.
2.2 The player can be moved by keyboard keys W S A D and rotated with Q and E.
2.3 The player can also be moved on the plane by input from an analog multi-axis USB joystick, such as a Thrustmaster T Flight-stick X.
2.3.1 Joystick forward - backward moves the player forward at a speed proportional to the joystick position.
2.3.2 Joystick left-right moves the player sideways at a speed proportional to the joystick position.
2.3.3 Joystick twist left-right rotates the player at a rate proportional to the amount of joystick twist.
2.3.4 The WSAD keys add 100% translation velocity and the QE keys add 100% rotation speed to the character controller on top of whatever the 0-100% signal is from the joystick.
3 World-space UI
********************
3.1 There is a one plane of scale (1,1,1) located at (0,0,0) with rotation (0,0,0)
3.2 On this plane there is a world-space UI toolkit document with several world-space buttons labeled Button 1 to Button 10.
The world space UI elements should be in a local coordinate system of the plane, such that the UI elements (aka buttons) can follow the two most nearby edges of the plane when the plane is moved/stretched/rotated.
3.3 Each button can be clicked with the computer mouse, as well as moved around on the plane with the mouse click-hold-drag-release.
3.4 When clicked, dragged or released, there is a corresponding log message “Button 1 pressed”, “Button 1 dragged” or “Button 1 released”.
3.5 By left-clicking and dragging near the corner of a button it can be resized.
3.6 By right-clicking and dragging a corner of a button it can be rotated.
3.7 By the mouse scroll-wheel the button can be resized.
3.8 The plane can be resized by mouse left click-drag near the corners and edge (in locations where there are not buttons), as well as moved by click-drag of locations within the plane further from the edges where there also are no buttons.
3.9 The plane can be rotated by right-click and drag.
3.10 Combining the keyboard SHIFT key with mouse LEFT, mouse RIGHT or mouse SCROLL-WHEEL will constrain the corresponding mouse actions to a suitable grid snap.
3.11 The translation, scaling and rotation of the plane is constrained by how much the mouse can move, and also by where the First Person Character controller is in relation to the plane.
I don´t think there is a need for limits as such on the movements of the plane, however if it makes the implementation easier or more robust, it can be done with limits.
3.12 By long left-click near the center of a button the button will become selected for editing. This is indicated by a bright colour change of the button outline.
In the selected state the button can be moved by the keyboard UP, DOWN, LEFT and RIGHT keys.
3.13 At any time a maximum of one button can be in the selected state.
3.14 A selected button is deselected when any other button (in either world-space or screen-space) is selected, clicked, dragged or rotated.
4 Screen-space UI
**********************
4.1 In screen-space there is an UI toolkit document with several screen-space buttons labeled Button 11 to Button 20, placed along the edges of the game window.
The screen-space UI document is intended to cover the whole of the Game Window, and this UI document is intended to be transparent (both to graphics and to screen-space mouse actions) everywhere except where the screen-space buttons are.
4.2 If the Windows game window size changes, these buttons move accordingly, such that these buttons keep their locations relative to the screen window edges.
4.3 These buttons can be clicked, dragged, resized and rotated similar to the world-space buttons, and give similar log messages.
4.4 The screen-space buttons will visually (and for mouse-actions) "float on top of" whatever is in the view of the world-space.
If a screen-space button blocks the view of a world-space button, the screen-space button has priority, both visually and for mouse actions.
If a screen space UI element, such as a Button is being moved, resized or rotated by mouse actions, care must be taken not to erroneously interact with any world-space object such as a world-space button or plane.