Crate univis_ui

Crate univis_ui 

Source
Expand description

§Univis UI

Univis is a high-performance, SDF-based world-space UI library designed for the Bevy Game Engine.

Unlike standard raster-based UI frameworks, Univis renders interface elements using Signed Distance Fields (SDF) directly on meshes. This approach ensures infinite resolution (crisp edges without pixelation) at any zoom level or camera angle, making it the ideal choice for:

  • Diegetic UI: Interfaces that exist within the game world (e.g., computer screens, holograms).
  • Sci-Fi HUDs: Complex, glowing, and animated heads-up displays.
  • VR/AR: Interfaces requiring high clarity and depth interaction.

§Key Features

  • Infinite Resolution: SDF rendering provides perfect anti-aliasing and rounded corners.
  • Advanced Layout Engine: A powerful, single-pass layout solver supporting:
    • Flexbox: Standard row/column layouts.
    • Grid: 2D grid arrangements.
    • Masonry: Pinterest-style packing.
    • Radial: Circular layouts for sci-fi menus.
  • ECS-Native: Fully integrated with Bevy’s ECS. All UI elements are standard Entities with Components.
  • Physics Ready: Elements interact with 3D lighting, depth, and physics (if configured).

§Quick Start

Add the UnivisUiPlugin to your App to initialize the library.

use bevy::prelude::*;
use univis::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(UnivisUiPlugin) // Initialize Univis
        .add_systems(Startup, setup_ui)
        .run();
}

fn setup_ui(mut commands: Commands) {
    // Create a World Space Root
    commands.spawn((
        UWorldRoot {
            size: Vec2::new(800.0, 600.0),
            resolution_scale: 1.0,
        },
        // Main Container
        UNode {
            width: UVal::Percent(1.0),
            height: UVal::Percent(1.0),
            background_color: Color::srgb(0.1, 0.1, 0.1),
            padding: USides::all(20.0),
            ..default()
        },
        ULayout {
            display: UDisplay::Flex,
            align_items: UAlignItems::Center,
            justify_content: UJustifyContent::Center,
            ..default()
        }
    )).with_children(|parent| {
        // Add a Label
        parent.spawn(UTextLabel {
            text: "Hello Univis!".into(),
            font_size: 32.0,
            color: Color::WHITE,
            ..default()
        });
    });
}

Modules§

interaction
layout
prelude
A convenient module that exports the most commonly used types and traits.
univis_debug
widget

Structs§

UnivisUiPlugin
The main plugin for the Univis UI library.