InputSystem Components
Main Components
InputManager
The central input component and the only place where raw mouse and touch input is read. It:
- Reads input each frame in
Update, using mouse handling on desktop and touch handling on Android. - Owns a
ClickDetectorand aDoubleClickDetector, and feeds them press and release data. - Raycasts each press against the EventSystem and calls
IInteractable.OnInteractionon matching components. - Exposes all gesture events as public delegate fields such as
Clicked,DoubleClicked, andDragStarted.
Typical use: subscribe through InputManager.Instance in your component's Start method, and unsubscribe in OnDisable.
InputHandler
A MonoBehaviour that connects InputManager to the UI system. It:
- Subscribes to
ClickedandDoubleClickedonInputManager.InstanceinStart. - Forwards each click to the UI pointer-click event and each double-click to the UI double-click event, using
UIEventFactory. - Unsubscribes in
OnDisable.
Use it when UI or gameplay code should listen to the EventBus instead of the InputManager delegates.
Key Event and Data Classes
ClickDetector
Plain C# class that tracks press time and raises OnClick when a press and release fall within InputConstants.ClickThreshold. Created by InputManager with that constant and this. It subscribes to Pressed and Released and has no unsubscribe method.
DoubleClickDetector
Plain C# class that takes timestamps from the caller through RegisterClick and raises OnDoubleClick for two clicks within its threshold. InputManager calls it on every press, not on every completed click. Drags call Reset on it.
InputConstants
Static class with one constant, ClickThreshold (0.2 seconds). This value is the click window used by ClickDetector.
Handler and Listener Interfaces
IInteractable
Implemented by components that should respond to a press on their GameObject. InputManager finds these on the hit object and its parents and calls OnInteraction.
IInteractionResponder
Defines OnInteracted for components that respond after an interaction.
Interaction with Dependency Classes
UIEventFactory
Used only by InputHandler. The factory creates and raises UI events on the EventBus. InputHandler calls it for clicks, passing the screen position, and for double-clicks. Listeners on the EventBus get those events without referencing InputManager.
EventBus
Receives the UI events raised through UIEventFactory. This system has no direct reference to it.