//! 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 [`entity::ButtonBundle`], [`entity::ImageBundle`], [`entity::TextBundle`] and [`entity::NodeBundle`] //! This UI is laid out with the Flexbox paradigm (see ) except the vertical axis is inverted mod flex; mod focus; mod geometry; mod render; mod ui_node; pub mod entity; pub mod update; pub mod widget; use bevy_render::extract_component::ExtractComponentPlugin; pub use flex::*; pub use focus::*; pub use geometry::*; pub use render::*; pub use ui_node::*; #[doc(hidden)] pub mod prelude { #[doc(hidden)] pub use crate::{entity::*, geometry::*, ui_node::*, widget::Button, Interaction, UiScale}; } use bevy_app::prelude::*; use bevy_ecs::{ schedule::{IntoSystemDescriptor, SystemLabel}, system::Resource, }; use bevy_input::InputSystem; use bevy_transform::TransformSystem; use bevy_window::ModifiesWindows; use update::{ui_z_system, update_clipping_system}; use crate::prelude::UiCameraConfig; /// The basic plugin for Bevy UI #[derive(Default)] pub struct UiPlugin; /// The label enum labeling the types of systems in the Bevy UI #[derive(Debug, Hash, PartialEq, Eq, Clone, SystemLabel)] pub enum UiSystem { /// After this label, the ui flex state has been updated Flex, /// After this label, input interactions with UI entities have been updated for this frame Focus, } /// The current scale of the UI. /// /// A multiplier to fixed-sized ui values. /// **Note:** This will only affect fixed ui values like [`Val::Px`] #[derive(Debug, Resource)] pub struct UiScale { /// The scale to be applied. pub scale: f64, } impl Default for UiScale { fn default() -> Self { Self { scale: 1.0 } } } impl Plugin for UiPlugin { fn build(&self, app: &mut App) { app.add_plugin(ExtractComponentPlugin::::default()) .init_resource::() .init_resource::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::() // NOTE: used by Style::aspect_ratio .register_type::>() .register_type::() .register_type::() .register_type::() .register_type::() .register_type::