1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
//! # bevy_ui_material
//!
//! Materials for bevy UI Nodes
//!
//! [](https://github.com/ManevilleF/bevy_ui_material/actions/workflows/rust.yaml)
//!
//! [](./LICENSE)
//! [](https://github.com/rust-secure-code/safety-dance/)
//! [](https://crates.io/crates/bevy_ui_material)
//! [](https://docs.rs/bevy_ui_material)
//! [](https://deps.rs/crate/bevy_ui_material)
//!
//! This [bevy] plugin changes the `bevy_ui` implementation using a material.
//!
//! > You might be interested in [bevy_sprite_material](https://github.com/ManevilleF/bevy_sprite_material) which is a similar plugin for `bevy_sprite` instead of `bevy_ui`.
//!
//! This plugin provides new implementation of the following bundles:
//! - `NodeBundle`
//! - `ButtonBundle`
//! - `ImageBundle`
//!
//! The new component bundles replaces the `color` field and the `image` field (`Handle<Image>`) by a `material` field (`Handle<ColorMaterial>`)
//!
//! ## Objective
//!
//! The goal of this plugin is to allow seamless edition of UI nodes `image` **and** `color` which was removed with [bevy] 0.6.
//!
//! This is very useful if you have many nodes and you have, for example, various themes and don't want to *query* every node to change its color.
//!
//! If you have a dedicated artist, you probably don't use the `color` tinting field anyway, so the base implementation is perfect for you.
//! This is specifically if you want to "massively update" the `color` and maybe the `image` as well.
//!
//! ## Disclaimer
//!
//! This plugin is very straightforward, and simply plugs itself in the `bevy_ui` render pipeline (in the *extraction* stage).
//! This system might be slower than the base implementation, because of the extra `Handle` involved.
//!
//! Also, there might be compatibility issues, so feel free to open issues or merge requests.
//!
//! > This plugin should work fine if you use both the plugin and the base ui implementation
//!
//! [bevy]: https://github.com/bevyengine/bevy
#![forbid(missing_docs)]
#![forbid(unsafe_code)]
#![warn(
clippy::all,
clippy::correctness,
clippy::suspicious,
clippy::style,
clippy::complexity,
clippy::perf,
clippy::nursery,
nonstandard_style,
rustdoc::broken_intra_links
)]
pub use bundle::*;
mod bundle;
mod extract;
use bevy_app::{App, Plugin};
use bevy_ecs::prelude::*;
use bevy_render::{RenderApp, RenderStage};
use bevy_ui::RenderUiSystem::ExtractNode;
/// Plugin ot use UI Nodes with materials
///
/// Requires [`bevy_ui::UiPlugin`]
#[derive(Default)]
pub struct UiMaterialPlugin;
impl Plugin for UiMaterialPlugin {
fn build(&self, app: &mut App) {
if let Ok(render_app) = app.get_sub_app_mut(RenderApp) {
render_app.add_system_to_stage(
RenderStage::Extract,
extract::extract_uinodes.after(ExtractNode),
);
}
}
}