/UnityRuntimeInputDebug

Simple Unity 3D input runtime debugger

Primary LanguageC#MIT LicenseMIT

Unity Runtime Input Debug

Simple unity input debug tool that displays currently pressed input on the screen.

Useful when recording gameplay demo for issue reporting or demonstrating how input is handled and translated into the game.

Current implementation depends on the legacy Unity Input System. I plan to extend the tools to support the new input system.

Table of Contents

Features
Installation
Usage
Examples
Credits

Features

  • Input capture

Displays currently held/active input on the screen

InputCapture

  • Input history

Displays latest handled input in a queue

InputHistory

Installation

Usage

Main entry point for the debugger is the InputDebugger component. The component and the code is documented with comments, tags and tooltips.

Default integration into projects

The debugger includes default prefab (preset) that can be used or extended in most of the cases.

  • Instantiate InputDebugger prefab when you need the input debugger or put it in the scene you want the debugger to be active
  • InputDebugger can be found in the Prefabs folder
  • The default preset:
    • has the input display debugger enabled by default
    • supports most of the keyboard keys and gamepad buttons
    • handles small number of the default axis from the Input Project Settings - Horizontal, Vertical, Mouse X, Mouse Y, Mouse ScrollWheel
    • is anchored in the top left part of the screen
    • doesn't capture mouse position and doesn't display input history queue

DefaultDebuggerSettings

Custom integration

The main component that you need to use is the InputDebugger component. The debugger is based on IMGUI so it's supposed to work wherever you attach it or instantiate it.

  • To use the debugger:

    • You can toggle the debugger on/off from the inspector enable/disable checkbox or from code - EnableInputDebugger()/DisableInputDebugger() functions.

    • You can toggle the input dislay debug from either the inspector InputDisplayEnabled checkbox or setting the same bool value from code

    • You must assign InputDebugCaptureActions scriptable object in the Input Actions field

    • InputDebugCaptureActions is a collection of all the keys and axis that the debugger must listen for. The collection is composed from Keys and Axis collections.

      • Keys collection contains KeyInputAction. If Icon is not assigned, the Name will be used during debugging.

        KeyInputActionExample

      • Axes collection contains AxisInputAction. If PositiveValueIcon and/or NegativeValueIcon are not assigned, AxisName will be used and the value will be displayed based on the AxisValueLabelPattern set in the InputDebugger.

        AxisInputActionExampe

    • DebugTextStyle is GUIStyle so you can configure it by your preferences. Note that the default value for the Normal style is BLACK!

    • Draw Anchor can be used to alter the position of the debugger. Currently supported - TopLeft, TopCenter, TopRight, MiddleLeft, Middle, MiddleRight, BottomLeft, BottomCenter, BottomRight.

  • To use the input history queue:

    • Enable it by toggling the InputHistoryEnabled property either by code or by the inspector

Examples

  • Example usage of the debugger in the Unity Open Project - Chop Chop!:

CaptureExample

  • You can check the included DemoScene in Assets/Scenes/ folder

Credits