InputSystem API Reference
All types are in the SaffronLibrary.Prime.Systems.Input namespace, except the interfaces, which are in SaffronLibrary.Prime.Systems.Input.Interfaces.
ClickDetector
Plain C# class that turns a press and release into a click when the elapsed time is within a threshold. Tracks the press time privately and resets it on each release.
public class ClickDetectorConstructor
public ClickDetector(float threshold, InputManager inputManager)threshold: The maximum time, in seconds, between press and release for the gesture to count as a click.inputManager: The source of rawPressedandReleasedevents. The constructor subscribes to both. There is no method to unsubscribe.
Events
public event Action<Vector3> OnClick;Raised on release when the press lasted no longer than the threshold. Carries the release position.
Methods
public void Reset()Clears the stored press time so that the next release does not produce a click.
DoubleClickDetector
Plain C# class that detects two clicks within a time window. The caller supplies the timestamps.
public class DoubleClickDetectorConstructor
public DoubleClickDetector(float threshold)threshold: The maximum time, in seconds, allowed between two clicks.
Events
public event Action OnDoubleClick;Raised when a click arrives within the threshold of the previous click. After firing, the detector returns to its initial state.
Methods
public void RegisterClick(float currentTime)Records a click at currentTime. The first call starts a new cycle. A later call within the threshold fires OnDoubleClick. A later call outside the threshold starts a new cycle with that click.
public void Reset()Clears any pending first click.
InputConstants
public static class InputConstantsFields
public const float ClickThreshold = 0.2f;The maximum time, in seconds, between press and release for a click. InputManager passes this value to ClickDetector.
InputHandler
public class InputHandler : MonoBehaviourForwards InputManager clicks and double-clicks to the UI event factory.
Methods
public void HandleClicked(Vector3 screenPosition)Raises the UI pointer-click event with the screen position.
public void HandleDoubleClicked(Vector3 screenPosition)Raises the UI double-click event. The position is received but not forwarded.
Lifecycle Behavior
StartsubscribesHandleClickedandHandleDoubleClickedtoInputManager.Instance.OnDisableunsubscribes both handlers.
InputManager
public class InputManager : MonoBehaviourCentral input component. Detects gestures on mouse or touch and exposes them as delegates. Persists across scenes once it is the active instance.
Static Fields
public static InputManager Instance;The active instance. Set in Awake. Duplicate instances are destroyed.
Public Delegate Fields
Each field carries the screen position.
public Action<Vector3> Pressed;
public Action<Vector3> Released;
public Action<Vector3> Held;
public Action<Vector3> Moved;
public Action<Vector3> Clicked;
public Action<Vector3> DoubleClicked;
public Action<Vector3> DragStarted;
public Action<Vector3> DragEnded;Pressed: Pointer went down. Carries the press position.Released: Pointer went up. Carries the release position.Held: Raised every frame while the pointer is down.Moved: Mouse position changed. Only raised on the mouse path.Clicked: Quick press and release without a drag.DoubleClicked: Two presses within the double-click window. CarriesUnityEngine.Input.mousePosition.DragStarted: Pointer moved beyond the drag threshold. Carries the press position.DragEnded: Release after a drag. Carries the release position.
Serialized Settings (private, Inspector-exposed)
doubleClickTime(default 0.3 seconds): Window used for double-click detection.dragThreshold(default 10 pixels): Distance the pointer must move from the press position to start a drag.
Methods
No public methods. The class uses private Awake, Update, HandleMouse, HandleTouch, ResolveHit, and OnHitResolved methods.
IInteractable
namespace SaffronLibrary.Prime.Systems.Input.Interfaces
{
public interface IInteractable
{
void OnInteraction();
}
}Implemented by components that should react when a press hits their GameObject or one of its children. InputManager calls OnInteraction on every IInteractable found on the hit object and its parents.
IInteractionResponder
namespace SaffronLibrary.Prime.Systems.Input.Interfaces
{
public interface IInteractionResponder
{
void OnInteracted();
}
}Declares a callback for components that respond after an interaction completes.