A draggable panel with a grip and a solid back
Updated
An inventory panel that a Behavior script makes draggable: a Grabbable, a UI Handle grip under it and an opaque UI Backdrop so it is not see-through from behind.
Drag the grip under the panel, or the panel itself, to move it. Drag the background to orbit round and see its solid back; scroll to zoom.
A draggable panel with a grip and a solid back
#pragma lifecycle(startup)
function startup() { const panel = findEntity('Inventory');
// Pointers and XR hands can drag it, by a handle along the bottom. panel.addComponent(new GrabbableComponent()); panel.addComponent(new UIHandleComponent({ placement: 'bottom', length: 96 }));
// An opaque back, so the panel is not see-through from behind. panel.addComponent(new UIBackdropComponent({ opacity: 1, padding: 4 }));
// Keep it in front of other overlapping panels. panel.getComponent(UILayoutComponent).setProps({ stackOrder: 50 });}How it works
Section titled “How it works”The script is explained step by step in A draggable panel with a grip and a solid back.
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.
DraggableInventory.xrproj