Snappable
Updated
Lets a media entity snap into Snap Zones.
- Type
comp-snappable- Script class
SnappableComponent- Per entity
- One
- Version
- 1.0.0
Read about it in Snap zones: what it does, how to use it from a script, and examples.
Events
Section titled “Events”Sent to the entity’s Signal Emitter as { entityId, eventType, data }. Compare eventType with the EventType constants.
Snappable::snapSnappable::unsnap
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
Live example
A custom backdrop that fits the zoneAn invisible Snap Zone wears a backdrop of its own: a one-by-one plane the script scales to the zone's size at startup and on every SnapZone::resize, as items fill the grid.
Drag the pictures onto the backdrop: it grows as the grid fills, and shrinks when you take them off. Drag elsewhere 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(SnappableComponent); if (component) log(component.props);}