InputState
此内容尚不支持你的语言。
Defined in: input/input.ts:77
This frame’s raw input — the layer under defineInputMap’s named actions.
@beta: per-frame touch state is reachable only as the raw touches /
touchesStarted / touchesEnded maps, so freezing it freezes two gaps in that
representation — no accessor for started/ended, and no write door at all.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new InputState():
InputState
Returns
Section titled “Returns”InputState
Properties
Section titled “Properties”gamepadButtonThreshold
Section titled “gamepadButtonThreshold”gamepadButtonThreshold:
number=0.5
Defined in: input/input.ts:219
Analog buttons (e.g. triggers) count as “down” at/above this value.
gamepadDeadzone
Section titled “gamepadDeadzone”gamepadDeadzone:
number=0.15
Defined in: input/input.ts:221
Axis magnitudes below this read as 0 (rest-position stick jitter).
gamepads
Section titled “gamepads”gamepads:
Map<number,PadState>
Defined in: input/input.ts:217
Per-index pad state; an index persists across disconnect so a reconnect resumes.
keysDown
Section titled “keysDown”keysDown:
Set<string>
Defined in: input/input.ts:78
keysPressed
Section titled “keysPressed”keysPressed:
Set<string>
Defined in: input/input.ts:79
keysPressedFixed
Section titled “keysPressedFixed”keysPressedFixed:
Set<string>
Defined in: input/input.ts:106
keysReleased
Section titled “keysReleased”keysReleased:
Set<string>
Defined in: input/input.ts:80
keysReleasedFixed
Section titled “keysReleasedFixed”keysReleasedFixed:
Set<string>
Defined in: input/input.ts:107
mouseButtons
Section titled “mouseButtons”mouseButtons:
Set<number>
Defined in: input/input.ts:83
mouseButtonsPressed
Section titled “mouseButtonsPressed”mouseButtonsPressed:
Set<number>
Defined in: input/input.ts:84
mouseButtonsPressedFixed
Section titled “mouseButtonsPressedFixed”mouseButtonsPressedFixed:
Set<number>
Defined in: input/input.ts:108
mouseButtonsReleased
Section titled “mouseButtonsReleased”mouseButtonsReleased:
Set<number>
Defined in: input/input.ts:85
mouseButtonsReleasedFixed
Section titled “mouseButtonsReleasedFixed”mouseButtonsReleasedFixed:
Set<number>
Defined in: input/input.ts:109
mouseX
Section titled “mouseX”mouseX:
number=0
Defined in: input/input.ts:81
mouseY
Section titled “mouseY”mouseY:
number=0
Defined in: input/input.ts:82
pointerOverUI
Section titled “pointerOverUI”pointerOverUI:
boolean=false
Defined in: input/input.ts:275
True when the pointer is over an interactive UI element this frame (set each
frame by the UI interaction system). Gameplay checks this to ignore input
the UI handled — e.g. don’t fire a weapon when clicking a HUD button.
Unity’s EventSystem.IsPointerOverGameObject() analog.
scrollDeltaX
Section titled “scrollDeltaX”scrollDeltaX:
number=0
Defined in: input/input.ts:86
scrollDeltaY
Section titled “scrollDeltaY”scrollDeltaY:
number=0
Defined in: input/input.ts:87
touchAvailable
Section titled “touchAvailable”touchAvailable:
boolean=false
Defined in: input/input.ts:90
Whether the device can be touched — asked of the platform, not of history.
touches
Section titled “touches”touches:
Map<number,TouchPoint>
Defined in: input/input.ts:92
touchesEnded
Section titled “touchesEnded”touchesEnded:
Set<number>
Defined in: input/input.ts:94
touchesStarted
Section titled “touchesStarted”touchesStarted:
Map<number,TouchPoint>
Defined in: input/input.ts:93
Methods
Section titled “Methods”beginFixedStep()
Section titled “beginFixedStep()”beginFixedStep():
void
Defined in: input/input.ts:338
Enter a fixed-timestep step: keyboard/mouse edge queries now read the fixed mirrors. Called by App before each FixedUpdate step.
Returns
Section titled “Returns”void
clearFrameState()
Section titled “clearFrameState()”clearFrameState():
void
Defined in: input/input.ts:325
Returns
Section titled “Returns”void
clearVirtual()
Section titled “clearVirtual()”clearVirtual():
void
Defined in: input/input.ts:211
Drop every virtual input — used when a control layer is torn down.
Returns
Section titled “Returns”void
endFixedStep()
Section titled “endFixedStep()”endFixedStep():
void
Defined in: input/input.ts:346
Leave a fixed step: drop the consumed edges (so a later step this frame doesn’t see them again) and restore the render context. Edges that arrived on a frame with no fixed step are never cleared here, so they survive to the next frame’s first step instead of being lost.
Returns
Section titled “Returns”void
getGamepadAxis()
Section titled “getGamepadAxis()”getGamepadAxis(
axis,pad?):number
Defined in: input/input.ts:259
Signed axis value in [-1,1], with the deadzone applied.
Parameters
Section titled “Parameters”number
number = 0
Returns
Section titled “Returns”number
getGamepadButtonValue()
Section titled “getGamepadButtonValue()”getGamepadButtonValue(
button,pad?):number
Defined in: input/input.ts:254
Raw analog value of a button in [0,1] (triggers; 0/1 for digital buttons).
Parameters
Section titled “Parameters”button
Section titled “button”number
number = 0
Returns
Section titled “Returns”number
getGamepads()
Section titled “getGamepads()”getGamepads():
number[]
Defined in: input/input.ts:224
Indices of currently-connected gamepads.
Returns
Section titled “Returns”number[]
getMousePosition()
Section titled “getMousePosition()”getMousePosition():
object
Defined in: input/input.ts:124
Returns
Section titled “Returns”object
x:
number
y:
number
getScrollDelta()
Section titled “getScrollDelta()”getScrollDelta():
object
Defined in: input/input.ts:171
Returns
Section titled “Returns”object
x:
number
y:
number
getTouch()
Section titled “getTouch()”getTouch(
id):TouchPoint|null
Defined in: input/input.ts:183
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”TouchPoint | null
getTouchCount()
Section titled “getTouchCount()”getTouchCount():
number
Defined in: input/input.ts:179
Returns
Section titled “Returns”number
getTouches()
Section titled “getTouches()”getTouches():
TouchPoint[]
Defined in: input/input.ts:175
Returns
Section titled “Returns”getVirtual()
Section titled “getVirtual()”getVirtual(
id):Vec2
Defined in: input/input.ts:206
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”injectGamepad()
Section titled “injectGamepad()”injectGamepad(
snapshot):void
Defined in: input/input.ts:291
Pads supplied by the HOST rather than by the hardware — a test harness, a driver, the editor’s agent. They outrank the poll at the same index: the poll runs every frame, so anything merely written into gamepads is gone before a system reads it.
Parameters
Section titled “Parameters”snapshot
Section titled “snapshot”Returns
Section titled “Returns”void
isGamepadButtonDown()
Section titled “isGamepadButtonDown()”isGamepadButtonDown(
button,pad?):boolean
Defined in: input/input.ts:234
Parameters
Section titled “Parameters”button
Section titled “button”number
number = 0
Returns
Section titled “Returns”boolean
isGamepadButtonPressed()
Section titled “isGamepadButtonPressed()”isGamepadButtonPressed(
button,pad?):boolean
Defined in: input/input.ts:239
Parameters
Section titled “Parameters”button
Section titled “button”number
number = 0
Returns
Section titled “Returns”boolean
isGamepadButtonReleased()
Section titled “isGamepadButtonReleased()”isGamepadButtonReleased(
button,pad?):boolean
Defined in: input/input.ts:246
Parameters
Section titled “Parameters”button
Section titled “button”number
number = 0
Returns
Section titled “Returns”boolean
isGamepadConnected()
Section titled “isGamepadConnected()”isGamepadConnected(
pad?):boolean
Defined in: input/input.ts:230
Parameters
Section titled “Parameters”number = 0
Returns
Section titled “Returns”boolean
isKeyDown()
Section titled “isKeyDown()”isKeyDown(
key):boolean
Defined in: input/input.ts:112
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
isKeyPressed()
Section titled “isKeyPressed()”isKeyPressed(
key):boolean
Defined in: input/input.ts:116
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
isKeyReleased()
Section titled “isKeyReleased()”isKeyReleased(
key):boolean
Defined in: input/input.ts:120
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
isMouseButtonDown()
Section titled “isMouseButtonDown()”isMouseButtonDown(
button):boolean
Defined in: input/input.ts:128
Parameters
Section titled “Parameters”button
Section titled “button”number
Returns
Section titled “Returns”boolean
isMouseButtonPressed()
Section titled “isMouseButtonPressed()”isMouseButtonPressed(
button):boolean
Defined in: input/input.ts:132
Parameters
Section titled “Parameters”button
Section titled “button”number
Returns
Section titled “Returns”boolean
isMouseButtonReleased()
Section titled “isMouseButtonReleased()”isMouseButtonReleased(
button):boolean
Defined in: input/input.ts:136
Parameters
Section titled “Parameters”button
Section titled “button”number
Returns
Section titled “Returns”boolean
isPointerOverUI()
Section titled “isPointerOverUI()”isPointerOverUI():
boolean
Defined in: input/input.ts:277
Returns
Section titled “Returns”boolean
isTouchActive()
Section titled “isTouchActive()”isTouchActive(
id):boolean
Defined in: input/input.ts:187
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”boolean
noteKeyDown()
Section titled “noteKeyDown()”noteKeyDown(
code):void
Defined in: input/input.ts:145
Record a key-down. The pressed edge only fires on the transition, so a browser’s auto-repeat keydown for a held key doesn’t re-trigger it.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
noteKeyUp()
Section titled “noteKeyUp()”noteKeyUp(
code):void
Defined in: input/input.ts:153
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
noteMouseDown()
Section titled “noteMouseDown()”noteMouseDown(
button):void
Defined in: input/input.ts:159
Parameters
Section titled “Parameters”button
Section titled “button”number
Returns
Section titled “Returns”void
noteMouseUp()
Section titled “noteMouseUp()”noteMouseUp(
button):void
Defined in: input/input.ts:165
Parameters
Section titled “Parameters”button
Section titled “button”number
Returns
Section titled “Returns”void
releaseGamepad()
Section titled “releaseGamepad()”releaseGamepad(
index?):void
Defined in: input/input.ts:296
Give an index (or all of them) back to the hardware.
Parameters
Section titled “Parameters”index?
Section titled “index?”number
Returns
Section titled “Returns”void
setVirtual()
Section titled “setVirtual()”setVirtual(
id,x,y?):void
Defined in: input/input.ts:201
Set a named virtual input; held until overwritten, so stopping means
writing zero. y defaults to 0 for button/1D use.
Parameters
Section titled “Parameters”string
number
number = 0
Returns
Section titled “Returns”void
updateGamepads()
Section titled “updateGamepads()”updateGamepads(
snapshots):void
Defined in: input/input.ts:303
Parameters
Section titled “Parameters”snapshots
Section titled “snapshots”Returns
Section titled “Returns”void