One Logo Pool Ball
RealityFoundation · IOS API REFERENCE

InputTargetComponent

struct · iOS 18.0+ · SDK 27.1

struct InputTargetComponent

A component that gives an entity the ability to receive system input. This component should be added to an entity to inform the system that it should be treated as a target for input handling. It can be customized to require only specific forms of input like direct or indirect interactions. By default the component is configured to handle all forms of input on the system. The hit testing shape that defines the entity's interactive entity is defined by the `CollisionComponent`. To configure an entity for input but avoid any sort of physics-related processing, add an `InputTargetComponent` and `CollisionComponent`, but disable the `CollisionComponent` for collision detection, for example: ``` // Enable the entity for input. myEntity.components.set(InputTargetComponent()) // Create a collision component with an empty group and mask. var collision = CollisionComponent(shapes: [.generateSphere(radius: 0.1)]) collision.filter = CollisionFilter(group: [], mask: []) myEntity.components.set(collision) ``` `InputTargetComponent` behaves hierarchically, so if it is added to an entity that has descendants with `CollisionComponent`s, those shapes will be used for input handling. The `isEnabled` flag can be used to override this behavior by adding the `InputTargetComponent` to a descendant and setting `isEnabled` to false. `InputTargetComponent`'s `allowedInputTypes` property allows the entity to only receive the provided types of input. This property also propagates down the hierarchy, but if a descendant also has an `InputTargetComponent` defined, its `allowedInputTypes` property overrides the value provided by the ancestor.

Members (5)

init · iOS 18.0+

init

TypeScript
static init(allowedInputTypes?: InputTargetComponent_InputType): InputTargetComponent
Swift declaration
init(allowedInputTypes: InputTargetComponent.InputType = .all)

Creates a new instance of an `InputTargetComponent` with a set of `allowedInputTypes` that define what kinds of input the component's entity can receive.

get · iOS 18.0+

allowedInputTypes

TypeScript
get allowedInputTypes(): InputTargetComponent_InputType
Swift declaration
var allowedInputTypes: InputTargetComponent.InputType

The set of input types this component's entity can receive.

set · iOS 18.0+

allowedInputTypes

TypeScript
set allowedInputTypes(value: InputTargetComponent_InputType)
Swift declaration
var allowedInputTypes: InputTargetComponent.InputType

The set of input types this component's entity can receive.

get · iOS 18.0+

isEnabled

TypeScript
get isEnabled(): boolean
Swift declaration
var isEnabled: Bool

Whether the component's entity is enabled for input.

set · iOS 18.0+

isEnabled

TypeScript
set isEnabled(value: boolean)
Swift declaration
var isEnabled: Bool

Whether the component's entity is enabled for input.

Skipped declarations

No declarations were skipped in this snapshot.

All RealityFoundation types →