forked from bevyengine/bevy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleaning up NodeBundle, and some slight UI module re-organization (be…
…vyengine#6473) # Objective `NodeBundle` contains an `image` field, which can be misleading, because if you do supply an image there, nothing will be shown to screen. You need to use an `ImageBundle` instead. ## Solution * `image` (`UiImage`) field is removed from `NodeBundle`, * extraction stage queries now make an optional query for `UiImage`, if one is not found, use the image handle that is used as a default by `UiImage`: https://github.com/bevyengine/bevy/blob/c019a60b39c5683656025bc9d24a02744aa59dea/crates/bevy_ui/src/ui_node.rs#L464 * touching up docs for `NodeBundle` to help guide what `NodeBundle` should be used for * renamed `entity.rs` to `node_bundle.rs` as that gives more of a hint regarding the module's purpose * separating `camera_config` stuff from the pre-made UI node bundles so that `node_bundle.rs` makes more sense as a module name.
- Loading branch information
Showing
5 changed files
with
62 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//! Configuration for cameras related to UI. | ||
use bevy_ecs::component::Component; | ||
use bevy_ecs::prelude::With; | ||
use bevy_ecs::query::QueryItem; | ||
use bevy_render::camera::Camera; | ||
use bevy_render::extract_component::ExtractComponent; | ||
|
||
/// Configuration for cameras related to UI. | ||
/// | ||
/// When a [`Camera`] doesn't have the [`UiCameraConfig`] component, | ||
/// it will display the UI by default. | ||
/// | ||
/// [`Camera`]: bevy_render::camera::Camera | ||
#[derive(Component, Clone)] | ||
pub struct UiCameraConfig { | ||
/// Whether to output UI to this camera view. | ||
/// | ||
/// When a `Camera` doesn't have the [`UiCameraConfig`] component, | ||
/// it will display the UI by default. | ||
pub show_ui: bool, | ||
} | ||
|
||
impl Default for UiCameraConfig { | ||
fn default() -> Self { | ||
Self { show_ui: true } | ||
} | ||
} | ||
|
||
impl ExtractComponent for UiCameraConfig { | ||
type Query = &'static Self; | ||
type Filter = With<Camera>; | ||
|
||
fn extract_component(item: QueryItem<'_, Self::Query>) -> Self { | ||
item.clone() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters