Show only the controls this scene needs
Updated
A 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.
Show only the controls this scene needs
#pragma lifecycle(startup)
function startup() { const cam = CameraDirector.main; const pad = cam && cam.getComponent(ScreenGamepadComponent); if (!pad) return;
// A walking scene: move, look and jump, plus one action button. pad.setProps({ buttons: ['leftStick', 'rightStick', 'a', 'x'], color: '#22c55e', opacity: 0.85 });
// ?pad=always shows it on a desktop too, for testing. if (WebBrowser.queryParams().pad === 'always') pad.setProps({ display: 'always' });
log(Device.isTouch() ? 'Touch controls ready' : 'Touch controls hidden on this device');}How it works
Section titled “How it works”The script is explained step by step in Show only the controls this scene needs.
Open it in XR Creator
Section titled “Open it in XR Creator”Download the project file below, then import it in XR Hub with Projects › New › Import, as described in Projects and templates. It opens in XR Creator with the same scene you see running above, each script already attached to its Behavior entity. From there you can edit the scripts, adjust components and their props, preview your changes, and deploy the result as a world of your own.
PadSetup.xrproj