Expand description
This crate contains Bevy’s UI system, which can be used to create UI for both 2D and 3D games
§Basic usage
Spawn UI elements with widget::Button
, ImageNode
, Text
and Node
This UI is laid out with the Flexbox and CSS Grid layout models (see https://cssreference.io/flexbox/)
Re-exports§
pub use measurement::*;
pub use ui_material::*;
Modules§
- box_
shadow - Box shadows rendering
- debug
- experimental
- Experimental features are not yet stable and may change or be removed in the future.
- graph
- measurement
- picking_
backend bevy_ui_picking_backend
- A picking backend for UI nodes.
- prelude
- The UI prelude.
- shader_
flags - The values here should match the values for the constants in
ui.wgsl
- stack_
z_ offsets - Z offsets of “extracted nodes” for a given entity. These exist to allow rendering multiple “extracted nodes” for a given source entity (ex: render both a background color and a custom material for a given node).
- ui_
material - ui_
texture_ slice_ pipeline - update
- This module contains systems that update the UI when something changes
- widget
- This module contains the basic building blocks of Bevy’s UI
Structs§
- Background
Color - The background color of the node
- Border
Color - The border color of the UI node.
- Border
Radius - Used to add rounded corners to a UI node. You can set a UI node to have uniformly rounded corners or specify different radii for each corner. If a given radius exceeds half the length of the smallest dimension between the node’s height or width, the radius will calculated as half the smallest dimension.
- BoxShadow
- List of shadows to draw for a
Node
. - BoxShadow
Samples - Number of shadow samples. A larger value will result in higher quality shadows. Default is 4, values higher than ~10 offer diminishing returns.
- Calculated
Clip - The calculated clip of the node
- Computed
Node - Provides the computed size and layout properties of the node.
- Computed
Node Target - Derived information about the camera target for this UI node.
- Default
UiCamera - Draw
UiMaterial Node - Draw
UiNode - Extracted
Glyph - Extracted
UiMaterial Node - Extracted
UiMaterial Nodes - Extracted
UiNode - Extracted
UiNodes - GlobalZ
Index GlobalZIndex
allows aNode
entity anywhere in the UI hierarchy to escape the implicit draw ordering of the UI’s layout tree and be rendered above or below other UI nodes. Nodes with aGlobalZIndex
of greater than 0 will be drawn on top of nodes without aGlobalZIndex
or nodes with a lowerGlobalZIndex
. Nodes with aGlobalZIndex
of less than 0 will be drawn below nodes without aGlobalZIndex
or nodes with a greaterGlobalZIndex
.- Grid
Placement - Represents the position of a grid item in a single axis.
- Grid
Track - A
GridTrack
is a Row or Column of a CSS Grid. This struct specifies what size the track should be. See below for the different “track sizing functions” you can specify. - Image
Node Bind Groups - IsDefault
UiCamera - Marker used to identify default cameras, they will have priority over the
PrimaryWindow
camera. - Layout
Config - This component can be added to any UI node to modify its layout behavior.
- Layout
Context - Node
- The base component for UI entities. It describes UI layout and style properties.
- Node
Query - Main query for
ui_focus_system
- Node
Query Item - Automatically generated
WorldQuery
item type forNodeQuery
, returned when iterating over query results. - Node
Query Read Only - Automatically generated
WorldQuery
type for a read-only variant ofNodeQuery
. - Node
Query Read Only Item - Automatically generated
WorldQuery
item type forNodeQueryReadOnly
, returned when iterating over query results. - Outline
- The
Outline
component adds an outline outside the edge of a UI node. Outlines do not take up space in the layout. - Overflow
- Whether to show or hide overflowing items
- Overflow
Clip Margin - The bounds of the visible area when a UI node is clipped.
- Prepared
UiMaterial - Relative
Cursor Position - A component storing the position of the mouse relative to the node, (0., 0.) being the top-left corner and (1., 1.) being the bottom-right If the mouse is not over the node, the value will go beyond the range of (0., 0.) to (1., 1.)
- Repeated
Grid Track - Represents a possibly repeated
GridTrack
. - Resolved
Border Radius - Represents the resolved border radius values for a UI node.
- Scroll
Position - The scroll position of the node.
- SetMat
UiView Bind Group - SetUi
Material Bind Group - SetUi
Texture Bind Group - SetUi
View Bind Group - Shadow
Style - State
- Contains entities whose Interaction should be set to None
- Text
Shadow - Adds a shadow behind text
- Transparent
Ui - UiBatch
- UiCamera
Map - UiCamera
Mapper - UiCamera
View - A render-world component that lives on the main render target view and specifies the corresponding UI view.
- UiDebug
Options bevy_ui_debug
- Configuration for the UI debug overlay
- UiMaterial
Batch - UiMaterial
Meta - UiMaterial
Pipeline - Render pipeline data for a given
UiMaterial
- UiMaterial
Plugin - Adds the necessary ECS resources and render logic to enable rendering entities using the given
UiMaterial
asset type (which includesUiMaterial
types). - UiMaterial
Vertex - UiMeta
- UiPass
Node - UiPipeline
- UiPipeline
Key - UiPlugin
- The basic plugin for Bevy UI
- UiRect
- A type which is commonly used to define margins, paddings and borders.
- UiScale
- The current scale of the UI.
- UiStack
- The current UI stack, which contains all UI nodes ordered by their depth (back-to-front).
- UiTarget
Camera - Indicates that this root
Node
entity should be rendered to a specific camera. - UiView
Target - A render-world component that lives on the UI view and specifies the corresponding main render target view.
- ZIndex
- Indicates that this
Node
entity’s front-to-back ordering is not controlled solely by its location in the UI hierarchy. A node with a higher z-index will appear on top of sibling nodes with a lower z-index.
Enums§
- Align
Content - Used to control how items are distributed.
- Align
Items - Used to control how each individual item is aligned by default within the space they’re given.
- Align
Self - Used to control how the specified item is aligned within the space it’s given.
- BoxSizing
- Which part of a Node’s box length styles like width and height control
- Display
- Defines the layout model used by this node.
- Extracted
UiItem - Flex
Direction - Defines how flexbox items are ordered within a flexbox
- Flex
Wrap - Defines if flexbox items appear on a single line or on multiple lines
- Focus
Policy - Describes whether the node should block interactions with lower nodes
- Grid
Auto Flow - Controls whether grid items are placed row-wise or column-wise as well as whether the sparse or dense packing algorithm is used.
- Grid
Placement Error - Errors that occur when setting constraints for a
GridPlacement
- Grid
Track Repetition - How many times to repeat a repeated grid track
- Interaction
- Describes what type of input interaction has occurred for a UI node.
- Justify
Content - Used to control how items are distributed.
- Justify
Items - Used to control how each individual item is aligned by default within the space they’re given.
- Justify
Self - Used to control how the specified item is aligned within the space it’s given.
- Layout
Error - MaxTrack
Sizing Function - MinTrack
Sizing Function - Node
Type - The type of UI node. This is used to determine how to render the UI node.
- Overflow
Axis - Whether to show or hide overflowing items
- Overflow
Clip Box - Used to determine the bounds of the visible area when a UI node is clipped.
- Position
Type - The strategy used to position this node
- Render
UiSystem - UiAnti
Alias - Marker for controlling whether Ui is rendered with or without anti-aliasing in a camera. By default, Ui is always anti-aliased.
- UiSystem
- The label enum labeling the types of systems in the Bevy UI
- Val
- Represents the possible value types for layout properties.
- ValArithmetic
Error - ValParse
Error
Constants§
Functions§
- build_
ui_ render - extract_
text_ sections - extract_
text_ shadows - extract_
ui_ camera_ view - Extracts all UI elements associated with a camera into the render world.
- extract_
ui_ material_ nodes - extract_
uinode_ background_ colors - extract_
uinode_ borders - extract_
uinode_ images - prepare_
uimaterial_ nodes - prepare_
uinodes - queue_
ui_ material_ nodes - queue_
uinodes - ui_
focus_ system - The system that sets Interaction for all UI elements based on the mouse cursor activity
- ui_
layout_ system - Updates the UI’s layout tree, computes the new layout geometry and then updates the sizes and transforms of all the UI nodes.