Class SpatialPointerDevice
An Input System device that exposes one primary spatial pointer and an array of additional spatial pointers, providing state suitable for spatial interactions (e.g., ray-based or direct interactions).
Inherited Members
Namespace: Unity.PolySpatial.InputDevices
Assembly: Unity.PolySpatial.Core.dll
Syntax
[InputControlLayout(stateType = typeof(SpatialPointerDeviceState))]
public class SpatialPointerDevice : InputDevice
Remarks
The device publishes a primary spatial pointer and up to MaxSpatialPointers additional pointer controls. It assigns a contiguous range of interaction IDs (touch IDs) for its pointers so that other systems can correlate events per device.
Properties
inputs
The collection of spatial pointer controls exposed by this device.
Declaration
public ReadOnlyArray<SpatialPointerControl> inputs { get; protected set; }
Property Value
| Type | Description |
|---|---|
| ReadOnlyArray<SpatialPointerControl> |
Remarks
The array length matches MaxSpatialPointers. Each control maps to a distinct spatial pointer and is associated with a stable interaction ID within the device's assigned range.
primaryInput
The primary spatial pointer control exposed by this device.
Declaration
public SpatialPointerControl primaryInput { get; protected set; }
Property Value
| Type | Description |
|---|---|
| SpatialPointerControl |
Remarks
This control mirrors the most relevant or active spatial pointer state at any given time and is used by systems that expect a single primary pointer. Its state is updated on incoming events and may reflect the most recent active pointer if multiple are present.
Methods
FinishSetup()
Completes control discovery and initializes device-specific state.
Declaration
protected override void FinishSetup()
Overrides
Remarks
Resolves the primaryInput and populates inputs with the remaining spatial pointer controls. Also assigns a contiguous range of interaction IDs (touch IDs) to this device so each pointer can be uniquely identified across devices.
GetStateOffsetForEvent(InputControl, InputEventPtr, ref uint)
Computes the byte offset into the device state for a given control and input event.
Declaration
public bool GetStateOffsetForEvent(InputControl control, InputEventPtr eventPtr, ref uint offset)
Parameters
| Type | Name | Description |
|---|---|---|
| InputControl | control | The control whose state offset is requested. If null, an offset corresponding to the pointer in the event is selected to facilitate InputUser iteration. |
| InputEventPtr | eventPtr | The input event for which to calculate the offset. Only state events with the SpatialPointerState format are supported. |
| uint | offset | On success, receives the byte offset from the start of the device state to the target pointer state. |
Returns
| Type | Description |
|---|---|
| bool | True if an appropriate offset could be determined; otherwise, false. |
Remarks
This mirrors the selection logic used by TouchScreen devices, allowing InputUser to iterate spatial pointer states in a predictable manner. When control is null, the method chooses the matching or next active pointer slot based on the event's interaction ID and phase.
OnNextUpdate()
Performs per-frame maintenance on pointer state before the next input update.
Declaration
public void OnNextUpdate()
Remarks
Resets the deltaInteractionPosition for all spatial pointers (including the primary pointer), ensuring that deltas only represent changes within the current frame/update.