Screen Gamepad
Updated
An on-screen gamepad with two sticks and four buttons, for touch screens.
- Type
comp-screen-gamepad- Script class
ScreenGamepadComponent- Per entity
- One
- Version
- 1.0.0
Read about it in Screen Gamepad: what it does, how to use it from a script, and examples.
Properties
Section titled “Properties”The props the runtime declares for this component, with their defaults and accepted ranges.
| Prop | Default | Range |
|---|---|---|
opacity |
0 ≤ x ≤ 1 |
|
padding[] |
0 ≤ x ≤ 10000 |
|
scale |
0 ≤ x ≤ 1 |
Events
Section titled “Events”Sent to the entity’s Signal Emitter as { entityId, eventType, data }. Compare eventType with the EventType constants.
ScreenGamepad::pressScreenGamepad::release
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
Live example
Show only the controls this scene needsA script reads the Screen Gamepad on the main camera and keeps only two sticks, A and X, recoloured green.
Watch the on-screen pad: the scene starts with only the sticks, A and X, in green. Drag to orbit the camera, scroll to zoom.
From a script
Section titled “From a script”#pragma lifecycle(startup)
function startup() { const component = self.parent.getComponent(ScreenGamepadComponent); if (component) log(component.props);}