Skip to main content

Interaction Input

NAMESPACEMyDreamGameStudio.InteractAnything
MENU PATHInteraction System > Core > Interaction Input
COMPATIBILITYUnity 6.0+
DOC VERSION

The InteractionInput component is the single central nervous system for hardware input. It is responsible for polling hardware events (keyboard and mouse) and dispatching them to the interaction framework.

In this system, Interactors act purely as sensors—they do not poll for input. Instead, this global input router determines which interactor should receive commands (e.g., routing input to the Examine Panel when an item is being inspected, or falling back to the world interactor) and triggers the appropriate execution methods.


Editor Interface​

INTERACTION INPUTHARDWARE ROUTERINPUT DISPATCHERThe central interaction input router. Reads bound hardware keys and dispatches Begin/Hold/Release interaction events to the active interactor.PRIMARY INTERACT BINDINGInteract BindingInteract KeyEAllow Left Mouse ClickOTHER SYSTEM BINDINGSNext Interactor KeyTabExamine Close KeyEscape

Configuration Variables​

Interact Key
KeyDef: E
The primary hardware key (via Unity Input System) used to trigger interactions.
Allow Left Mouse Click
boolDef: True
If enabled, pressing the Left Mouse Button is treated identically to pressing the Interact Key. Essential for point-and-click setups utilizing the CursorInteractor.
Next/Prev Interactor Key
Key
Optional bindings that automatically hook into the InteractionModeSwitcher Singleton to cycle the active simulation state (e.g., pressing Tab to switch from FPS crosshair to free-mouse cursor).
Examine Close Key
KeyDef: Escape
The dedicated key used to exit the 3D inspection viewport managed by the ExaminePanel.

Custom Input Routing​

The InteractionInput component works perfectly out-of-the-box using the built-in UnityEngine.InputSystem polling. However, if your project relies on on-screen mobile UI buttons, a gamepad manager, or a heavy third-party package like Rewired, you do not need to rewrite this class.

The script exposes public Trigger methods. You can simply turn off the default polling (or leave the bindings unmapped) and call these methods directly from your own input events. The router will still handle the complex logic of determining which interactor should receive the input.

Bypassing Default Input​

Route your custom interaction events directly through the Singleton instance:

public class CustomMobileInput : MonoBehaviour
{
// Called by a Unity UI Event Trigger on a mobile screen button (PointerDown)
public void OnMobileInteractButtonPressed()
{
InteractionInput.Instance.TriggerInteractPressed();
}

// Called every frame the mobile button is held down
public void OnMobileInteractButtonHeld()
{
InteractionInput.Instance.TriggerInteractHeld();
}

// Called by a Unity UI Event Trigger on a mobile screen button (PointerUp)
public void OnMobileInteractButtonReleased()
{
InteractionInput.Instance.TriggerInteractReleased();
}
}