Rename CameraUi (#5234)
# Objective In bevy 0.7, `CameraUi` was a component specifically added to cameras that display the UI. Since camera-driven rendering was merged, it actually does the opposite! This will make it difficult for current users to adapt to 0.8. ## Solution To avoid unnecessary confusion, we rename `CameraUi` into `UiCameraConfig`. --- ## Changelog - Rename `CameraUi` to `UiCameraConfig`
This commit is contained in:
parent
cf200f09dd
commit
4ee73ed904
@ -136,18 +136,28 @@ impl Default for ButtonBundle {
|
||||
}
|
||||
}
|
||||
}
|
||||
/// 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 CameraUi {
|
||||
pub is_enabled: bool,
|
||||
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 CameraUi {
|
||||
impl Default for UiCameraConfig {
|
||||
fn default() -> Self {
|
||||
Self { is_enabled: true }
|
||||
Self { show_ui: true }
|
||||
}
|
||||
}
|
||||
|
||||
impl ExtractComponent for CameraUi {
|
||||
impl ExtractComponent for UiCameraConfig {
|
||||
type Query = &'static Self;
|
||||
type Filter = With<Camera>;
|
||||
|
||||
|
@ -33,7 +33,7 @@ use bevy_transform::TransformSystem;
|
||||
use bevy_window::ModifiesWindows;
|
||||
use update::{ui_z_system, update_clipping_system};
|
||||
|
||||
use crate::prelude::CameraUi;
|
||||
use crate::prelude::UiCameraConfig;
|
||||
|
||||
/// The basic plugin for Bevy UI
|
||||
#[derive(Default)]
|
||||
@ -50,7 +50,7 @@ pub enum UiSystem {
|
||||
|
||||
impl Plugin for UiPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_plugin(ExtractComponentPlugin::<CameraUi>::default())
|
||||
app.add_plugin(ExtractComponentPlugin::<UiCameraConfig>::default())
|
||||
.init_resource::<FlexSurface>()
|
||||
.register_type::<AlignContent>()
|
||||
.register_type::<AlignItems>()
|
||||
|
@ -5,7 +5,7 @@ use bevy_core_pipeline::{core_2d::Camera2d, core_3d::Camera3d};
|
||||
pub use pipeline::*;
|
||||
pub use render_pass::*;
|
||||
|
||||
use crate::{prelude::CameraUi, CalculatedClip, Node, UiColor, UiImage};
|
||||
use crate::{prelude::UiCameraConfig, CalculatedClip, Node, UiColor, UiImage};
|
||||
use bevy_app::prelude::*;
|
||||
use bevy_asset::{load_internal_asset, AssetEvent, Assets, Handle, HandleUntyped};
|
||||
use bevy_ecs::prelude::*;
|
||||
@ -227,14 +227,11 @@ pub struct DefaultCameraView(pub Entity);
|
||||
pub fn extract_default_ui_camera_view<T: Component>(
|
||||
mut commands: Commands,
|
||||
render_world: Res<RenderWorld>,
|
||||
query: Query<(Entity, &Camera, Option<&CameraUi>), With<T>>,
|
||||
query: Query<(Entity, &Camera, Option<&UiCameraConfig>), With<T>>,
|
||||
) {
|
||||
for (entity, camera, camera_ui) in query.iter() {
|
||||
// ignore cameras with disabled ui
|
||||
if let Some(&CameraUi {
|
||||
is_enabled: false, ..
|
||||
}) = camera_ui
|
||||
{
|
||||
if matches!(camera_ui, Some(&UiCameraConfig { show_ui: false, .. })) {
|
||||
continue;
|
||||
}
|
||||
if let (Some(logical_size), Some(physical_size)) = (
|
||||
|
@ -1,5 +1,5 @@
|
||||
use super::{UiBatch, UiImageBindGroups, UiMeta};
|
||||
use crate::{prelude::CameraUi, DefaultCameraView};
|
||||
use crate::{prelude::UiCameraConfig, DefaultCameraView};
|
||||
use bevy_ecs::{
|
||||
prelude::*,
|
||||
system::{lifetimeless::*, SystemParamItem},
|
||||
@ -20,7 +20,7 @@ pub struct UiPassNode {
|
||||
(
|
||||
&'static RenderPhase<TransparentUi>,
|
||||
&'static ViewTarget,
|
||||
Option<&'static CameraUi>,
|
||||
Option<&'static UiCameraConfig>,
|
||||
),
|
||||
With<ExtractedView>,
|
||||
>,
|
||||
@ -66,7 +66,7 @@ impl Node for UiPassNode {
|
||||
return Ok(());
|
||||
}
|
||||
// Don't render UI for cameras where it is explicitly disabled
|
||||
if let Some(&CameraUi { is_enabled: false }) = camera_ui {
|
||||
if matches!(camera_ui, Some(&UiCameraConfig { show_ui: false })) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user