A HUD that moves between corners
Updated
Each press of Move steps a screen-space HUD round the four corners of the screen by changing its UI Screen Space anchor.
Press Move to send the HUD to the next corner of the screen.
A HUD that moves between corners
#pragma lifecycle(startup)
// Scene: a UI Panel named 'HUD' with a UI Screen Space component,// containing a UI Button named 'Move' whose Signal Emitter uses 'hud/move'.const CORNERS = ['top-left', 'top-right', 'bottom-right', 'bottom-left'];let index = 0;
function startup() { const screen = findEntity('HUD').getComponent(UIScreenSpaceComponent); screen.setProps({ anchor: CORNERS[index], insetX: 16, insetY: 16 });
on('hud/move', (event) => { if (event.eventType !== EventType.UIButton.Press) return; index = (index + 1) % CORNERS.length; screen.setProps({ anchor: CORNERS[index] }); });}How it works
Section titled “How it works”The script is explained step by step in A HUD that moves between corners.
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.
HudCorner.xrproj