bevy_world_space_ui

Crates.iobevy_world_space_ui
lib.rsbevy_world_space_ui
version0.1.3
created_at2025-08-09 05:23:27.184835+00
updated_at2025-08-09 06:08:48.114506+00
descriptionMake building world space UIs easier in Bevy game engine.
homepagehttps://github.com/Katsutoshii/bevy_world_space_ui
repositoryhttps://github.com/Katsutoshii/bevy_world_space_ui
max_upload_size
id1787587
size148,790
Josiah Putman (Katsutoshii)

documentation

https://docs.rs/bevy_world_space_ui/latest/bevy_world_space_ui

README

bevy_world_space_ui

License Crates.io Docs

Make building world space UIs easier in Bevy game engine.

Usage

use bevy_world_space_ui::{WorldSpaceUiPlugin, WorldSpaceUiRoot, WorldSpaceUiSurface};

// Generate your own pointer ID.
const WORLD_SPACE_UI_POINTER: PointerId = PointerId::Custom(Uuid::from_u128(123));

fn main() {
    App::new()
        .add_plugins((DefaultPlugins, WorldSpaceUiPlugin))
        .add_systems(Startup, setup)
        .run();
}

fn setup(
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
    mut images: ResMut<Assets<Image>>,
) {
    // Create the texture to be rendered to.
    let resolution = Extent3d {
        width: 512,
        height: 512,
        ..default()
    };
    let image_handle = images.add(WorldSpaceUiRoot::get_ui_texture(resolution));

    // Spawn your UI with `WorldSpaceUiRoot`.
    let root = commands
        .spawn((
            WorldSpaceUiRoot {
                texture: image_handle.clone(),
            },
            // Spawn your UI tree...
        ))
        .id();

    // Spawn a quad to render the UI on.
    commands.spawn((
        Mesh3d(meshes.add(Rectangle::default())),
        WorldSpaceUiSurface {
            root,
            texture: image_handle.clone(),
            pointer_id: WORLD_SPACE_UI_POINTER,
            ..default()
        },
        Transform::from_xyz(0.0, 0.0, 1.5).with_rotation(Quat::from_axis_angle(Vec3::X, PI / 8.)),
    ));

    // Setup cameras and lights as you normally would.
    // ...
}

See examples for a working demo.

Bevy support table

bevy bevy_world_space_ui
0.16 0.1.3
Commit count: 0

cargo fmt