XRC Students wi2024-ws03-tl838
Overview
This package is a Input Tool which can be used to visualize all the active input actions related to specific controller parts. It can be used to debug the input actions and to check if the input actions are triggered correctly.
Components
Input Tool
This component contains the main logic for the Input Tool. Requires list of input action assets and a controller mapping. This component will check which input actions in the given input action assets are active and map them to the controller parts provided by the controller mapping. The Input Tool will be ready when activated by the user assigned input actions, and the active input actions will be exposed in a dictionary that maps a controller part to a list of strings that are the names of the active input actions.
Property | Description |
---|---|
Controller Mapping | The scriptable object that contains the mapping to the controller parts specified by the user |
Input Action Assets | List of input action assets that are to be visualized |
Input Tool Input
This component handles user input, and activates the Input Tool with the user specified input actions.
Property | Description |
---|---|
Input Tool Action | The InputActionProperty to activate and deactivate the Input Tool |
Input Tool Feedback
This component displays the currently active input actions on the controller, using labels and leader lines linking to the controller parts.
Labels as well as leader lines for each controller part specified in the controller mapping will be generated on-the-fly.
The labels will be updated as the input action status changes, and will follow the controller part at the specified speed.
This component consumes the exposed dictionary of controller parts and input actions from
Property | Description |
---|---|
Left Action Based Controller | Left action based controller used in the scene, should align with your scriptable object and the controller model set in the XR Origin |
Right Action Based Controller | Right action based controller used in the scene, should align with your scriptable object and the controller model set in the XR Origin |
Look At Camera | Camera that the labels will be looking at, this decides the orientation of the labels, defaults to main camera if not specified |
Leader Line Color | The color for the line connecting the label to the controller part |
Title Color | Title color for contents in the labels |
Text Color | Body text color for contents in the labels |
Label Following Speed | The following speed of the labels, higher value means faster following speed |
Transition Duration | The transition duration of the intro and outro for labels, higher value means faster transition speed |
Enable Transition | Whether to enable transition for labels, if set to false, labels will appear and disappear instantly |
Hide Labels For Inactive Parts | Whether to hide labels for inactive controller parts, if set to true, labels will only be shown for active controller parts |
Hide Labels When Input Tool Disabled | Whether to hide labels when the Input Tool is disabled, if set to true, labels will only be shown when the Input Tool is active |
Controller Mapping
The Scriptable Object to store the controller mappings, which maps a controller part to a user specified model name. A custom editor is provided to allow the user to specify the controller parts and the corresponding model names. Drag the game object of the controller part into the game object field, and specify the part it represents in the controller part field.
Property | Description |
---|---|
Drag Game Object Here | The game object field for the controller part model |
Name | The name of the controller controller part model |
Controller Part | The enumeration of supported controller parts |
Bezier Curve
This component draws a bezier curve from a starting point transform to an end point transform. It takes a line renderer as well as the start and end point to draw the curve. Also takes a boolean to decide whether to inverse the starting bend direction of the curve.
Property | Description |
---|---|
Update Tracking Type | The update tracking type of the bezier curve, defines the time within the frame that the curve will be updated. |
Start Point | The transform that determines the start point of the bezier curve |
End Point | The transform that determines the end point of the bezier curve |
Line Renderer | The line renderer that draws the bezier curve |
Curve Factor Start | The curve factor of the start Bezier handle determines the extent of the curve's initial bend. Higher values create a more pronounced or steeper curve at the start. |
Curve Factor End | The curve factor of the end Bezier handle determines the extent of the curve's final bend. Higher values create a more pronounced or steeper curve at the end. |
Segment Count | The number of segments used to draw the bezier curve, Higher values create a smoother curve. |
Should Inverse Start Direction | Whether to inverse the starting bend direction of the curve. |
Installation instructions
To install this package, follow these steps:
- In the Unity Editor, click on Window > Package Manager
- Click the + button and choose Add package from git URL option
- Paste the URL to the package repository: https://github.com/xrc-students/xrc-students-wi2024-ws03-tl838.git in the prompt and click on Add (make sure your URL ends with ".git")
- If the repository is private, you will be asked to authenticate via your GitHub account. If you haven't been granted access to the repository you will not be able to install the package.
- The package should be installed into your project
- You can download the package samples from under the Samples tab in the Package Manager
Note: Even though the package documentation is public, several XRC packages are private and accessible only to XRC staff and students.
Requirements
This package was developed and tested using the following Unity Editor version:
- 2022.3.7f1 LTS
Dependencies: XRC Core, XR Interaction Toolkit, Input System.
Limitations
Currently, the InputTool works well on Oculus devices. If supports for other devices are needed, the input action binding strings might need to be changed accordingly.
Currently supported controller types:
<XRController>
<OculusTouchController>
<QuestProTouchController>
Currently supported action types:
Grip
Trigger
PrimaryButton
SecondaryButton
Thumbstick (Primary2DAxis)
ThumbstickClick (Primary2DAxisClick>)
MenuButton (Menu, Start)
More actions can be added by adding the corresponding input action binding strings to the Input Tool component, and updating the controller mapping accordingly.
Workflows
When adding the Input Tool to your scene you can do any of the following:
- Add the three Input Tool component directly on the an empty game object.
- Create a new InputTool directly in the scene hierarchy from the context menu, as shown in the screenshot below.
You will need to create a controller mapping scriptable object to map the controller parts to the controller models, as it is required by the Input Tool component. You can create a new controller mapping scriptable object with the following steps:
- Right click in the project window and select Create > InputTool > ControllerMapping.
- Open your controller prefab in the scene and have the Controller Mapping in the inspector.
- Click Add New to add a new controller part.
- Drag and drop the controller parts from the prefab hierarchy into the game object field of the controller mapping.
- Select the corresponding controller part from the drop down menu of the controller part field.
- You can remove the controller part by clicking the Remove button, and keep adding new controller parts until you have mapped all the controller parts you want to visualize.
You will also need to assign the input actions you want the Input Tool to manage in the Input Action Assets field of the Input Tool component.
Advanced topics
Labels are current placed in default positions around the controller parts, and the positions are not configurable. In some cases, the labels might be blocked by the controller parts or other labels, as well as other objects in the scene. Label placement algorithm can be implemented to solve this problem.
Preliminary label placement algorithm is implemented at Input Tool with Label Placement Algorithm
Reference
Samples
XRC Input Tool
A sample scene to demonstrate the usage of the Input Tool.
Video Demo
Video Demo using the Input Tool in Fall 2023 Project (3D Design Tool)