Rename TargetCamera to UiTargetCamera (#17403)

# Objective

It's not immediately obvious that `TargetCamera` only works with UI node
entities. It's natural to assume from looking at something like the
`multiple_windows` example that it will work with everything.

## Solution

Rename `TargetCamera` to `UiTargetCamera`.

## Migration Guide

`TargetCamera` has been renamed to `UiTargetCamera`.
This commit is contained in:
ickshonpe 2025-01-19 19:56:57 +00:00 committed by GitHub
parent 7c8da1c05d
commit adc33b5108
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 68 additions and 62 deletions

View File

@ -294,7 +294,7 @@ pub fn debug_draw(
}, },
)) ))
.insert(Pickable::IGNORE) .insert(Pickable::IGNORE)
.insert(TargetCamera(camera)); .insert(UiTargetCamera(camera));
} }
} }
} }

View File

@ -1,5 +1,5 @@
use crate::{ use crate::{
CalculatedClip, ComputedNode, DefaultUiCamera, ResolvedBorderRadius, TargetCamera, UiStack, CalculatedClip, ComputedNode, DefaultUiCamera, ResolvedBorderRadius, UiStack, UiTargetCamera,
}; };
use bevy_ecs::{ use bevy_ecs::{
change_detection::DetectChangesMut, change_detection::DetectChangesMut,
@ -141,7 +141,7 @@ pub struct NodeQuery {
focus_policy: Option<&'static FocusPolicy>, focus_policy: Option<&'static FocusPolicy>,
calculated_clip: Option<&'static CalculatedClip>, calculated_clip: Option<&'static CalculatedClip>,
view_visibility: Option<&'static ViewVisibility>, view_visibility: Option<&'static ViewVisibility>,
target_camera: Option<&'static TargetCamera>, target_camera: Option<&'static UiTargetCamera>,
} }
/// The system that sets Interaction for all UI elements based on the mouse cursor activity /// The system that sets Interaction for all UI elements based on the mouse cursor activity
@ -239,7 +239,7 @@ pub fn ui_focus_system(
} }
let camera_entity = node let camera_entity = node
.target_camera .target_camera
.map(TargetCamera::entity) .map(UiTargetCamera::entity)
.or(default_camera_entity)?; .or(default_camera_entity)?;
let node_rect = Rect::from_center_size( let node_rect = Rect::from_center_size(

View File

@ -1,7 +1,7 @@
use crate::{ use crate::{
experimental::{UiChildren, UiRootNodes}, experimental::{UiChildren, UiRootNodes},
BorderRadius, ComputedNode, ContentSize, DefaultUiCamera, Display, LayoutConfig, Node, Outline, BorderRadius, ComputedNode, ContentSize, DefaultUiCamera, Display, LayoutConfig, Node, Outline,
OverflowAxis, ScrollPosition, TargetCamera, UiScale, Val, OverflowAxis, ScrollPosition, UiScale, UiTargetCamera, Val,
}; };
use bevy_ecs::{ use bevy_ecs::{
entity::{EntityHashMap, EntityHashSet}, entity::{EntityHashMap, EntityHashSet},
@ -105,7 +105,7 @@ pub fn ui_layout_system(
Entity, Entity,
Ref<Node>, Ref<Node>,
Option<&mut ContentSize>, Option<&mut ContentSize>,
Option<&TargetCamera>, Option<&UiTargetCamera>,
)>, )>,
computed_node_query: Query<(Entity, Option<Ref<Parent>>), With<ComputedNode>>, computed_node_query: Query<(Entity, Option<Ref<Parent>>), With<ComputedNode>>,
ui_children: UiChildren, ui_children: UiChildren,
@ -132,8 +132,8 @@ pub fn ui_layout_system(
let (cameras, default_ui_camera) = camera_data; let (cameras, default_ui_camera) = camera_data;
let default_camera = default_ui_camera.get(); let default_camera = default_ui_camera.get();
let camera_with_default = |target_camera: Option<&TargetCamera>| { let camera_with_default = |target_camera: Option<&UiTargetCamera>| {
target_camera.map(TargetCamera::entity).or(default_camera) target_camera.map(UiTargetCamera::entity).or(default_camera)
}; };
resized_windows.clear(); resized_windows.clear();
@ -165,7 +165,7 @@ pub fn ui_layout_system(
Some(camera_entity) => { Some(camera_entity) => {
let Ok((_, camera)) = cameras.get(camera_entity) else { let Ok((_, camera)) = cameras.get(camera_entity) else {
warn!( warn!(
"TargetCamera (of root UI node {entity}) is pointing to a camera {} which doesn't exist", "UiTargetCamera (of root UI node {entity}) is pointing to a camera {} which doesn't exist",
camera_entity camera_entity
); );
return; return;
@ -181,7 +181,7 @@ pub fn ui_layout_system(
} else { } else {
warn!( warn!(
"Multiple cameras found, causing UI target ambiguity. \ "Multiple cameras found, causing UI target ambiguity. \
To fix this, add an explicit `TargetCamera` component to the root UI node {}", To fix this, add an explicit `UiTargetCamera` component to the root UI node {}",
entity entity
); );
} }
@ -621,7 +621,7 @@ mod tests {
let camera_entity = world.spawn(Camera2d).id(); let camera_entity = world.spawn(Camera2d).id();
let ui_entity = world let ui_entity = world
.spawn((Node::default(), TargetCamera(camera_entity))) .spawn((Node::default(), UiTargetCamera(camera_entity)))
.id(); .id();
// `ui_layout_system` should map `camera_entity` to a ui node in `UiSurface::camera_entity_to_taffy` // `ui_layout_system` should map `camera_entity` to a ui node in `UiSurface::camera_entity_to_taffy`
@ -926,7 +926,7 @@ mod tests {
for moving_ui_entity in moving_ui_query.iter() { for moving_ui_entity in moving_ui_query.iter() {
commands commands
.entity(moving_ui_entity) .entity(moving_ui_entity)
.insert(TargetCamera(target_camera_entity)) .insert(UiTargetCamera(target_camera_entity))
.insert(Node { .insert(Node {
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
top: Val::Px(pos.y), top: Val::Px(pos.y),
@ -944,8 +944,8 @@ mod tests {
) { ) {
world.run_system_once_with(move_ui_node, new_pos).unwrap(); world.run_system_once_with(move_ui_node, new_pos).unwrap();
ui_schedule.run(world); ui_schedule.run(world);
let (ui_node_entity, TargetCamera(target_camera_entity)) = world let (ui_node_entity, UiTargetCamera(target_camera_entity)) = world
.query_filtered::<(Entity, &TargetCamera), With<MovingUiNode>>() .query_filtered::<(Entity, &UiTargetCamera), With<MovingUiNode>>()
.get_single(world) .get_single(world)
.expect("missing MovingUiNode"); .expect("missing MovingUiNode");
assert_eq!(expected_camera_entity, target_camera_entity); assert_eq!(expected_camera_entity, target_camera_entity);

View File

@ -153,7 +153,7 @@ impl Plugin for UiPlugin {
.register_type::<Node>() .register_type::<Node>()
.register_type::<RelativeCursorPosition>() .register_type::<RelativeCursorPosition>()
.register_type::<ScrollPosition>() .register_type::<ScrollPosition>()
.register_type::<TargetCamera>() .register_type::<UiTargetCamera>()
.register_type::<ImageNode>() .register_type::<ImageNode>()
.register_type::<ImageNodeSize>() .register_type::<ImageNodeSize>()
.register_type::<UiRect>() .register_type::<UiRect>()

View File

@ -51,7 +51,7 @@ pub struct NodeQuery {
pickable: Option<&'static Pickable>, pickable: Option<&'static Pickable>,
calculated_clip: Option<&'static CalculatedClip>, calculated_clip: Option<&'static CalculatedClip>,
view_visibility: Option<&'static ViewVisibility>, view_visibility: Option<&'static ViewVisibility>,
target_camera: Option<&'static TargetCamera>, target_camera: Option<&'static UiTargetCamera>,
} }
/// Computes the UI node entities under each pointer. /// Computes the UI node entities under each pointer.
@ -132,7 +132,7 @@ pub fn ui_picking(
} }
let Some(camera_entity) = node let Some(camera_entity) = node
.target_camera .target_camera
.map(TargetCamera::entity) .map(UiTargetCamera::entity)
.or(default_camera_entity) .or(default_camera_entity)
else { else {
continue; continue;
@ -188,7 +188,7 @@ pub fn ui_picking(
for node in node_query.iter_many(hovered_nodes) { for node in node_query.iter_many(hovered_nodes) {
let Some(camera_entity) = node let Some(camera_entity) = node
.target_camera .target_camera
.map(TargetCamera::entity) .map(UiTargetCamera::entity)
.or(default_camera_entity) .or(default_camera_entity)
else { else {
continue; continue;

View File

@ -4,7 +4,7 @@ use core::{hash::Hash, ops::Range};
use crate::{ use crate::{
BoxShadow, BoxShadowSamples, CalculatedClip, ComputedNode, DefaultUiCamera, RenderUiSystem, BoxShadow, BoxShadowSamples, CalculatedClip, ComputedNode, DefaultUiCamera, RenderUiSystem,
ResolvedBorderRadius, TargetCamera, TransparentUi, Val, ResolvedBorderRadius, TransparentUi, UiTargetCamera, Val,
}; };
use bevy_app::prelude::*; use bevy_app::prelude::*;
use bevy_asset::*; use bevy_asset::*;
@ -246,7 +246,7 @@ pub fn extract_shadows(
&ViewVisibility, &ViewVisibility,
&BoxShadow, &BoxShadow,
Option<&CalculatedClip>, Option<&CalculatedClip>,
Option<&TargetCamera>, Option<&UiTargetCamera>,
)>, )>,
>, >,
mapping: Extract<Query<RenderEntity>>, mapping: Extract<Query<RenderEntity>>,
@ -255,7 +255,8 @@ pub fn extract_shadows(
for (entity, uinode, transform, view_visibility, box_shadow, clip, camera) in &box_shadow_query for (entity, uinode, transform, view_visibility, box_shadow, clip, camera) in &box_shadow_query
{ {
let Some(camera_entity) = camera.map(TargetCamera::entity).or(default_camera_entity) else { let Some(camera_entity) = camera.map(UiTargetCamera::entity).or(default_camera_entity)
else {
continue; continue;
}; };

View File

@ -1,7 +1,7 @@
use crate::CalculatedClip; use crate::CalculatedClip;
use crate::ComputedNode; use crate::ComputedNode;
use crate::DefaultUiCamera; use crate::DefaultUiCamera;
use crate::TargetCamera; use crate::UiTargetCamera;
use bevy_asset::AssetId; use bevy_asset::AssetId;
use bevy_color::Hsla; use bevy_color::Hsla;
use bevy_ecs::entity::Entity; use bevy_ecs::entity::Entity;
@ -66,7 +66,7 @@ pub fn extract_debug_overlay(
&ViewVisibility, &ViewVisibility,
Option<&CalculatedClip>, Option<&CalculatedClip>,
&GlobalTransform, &GlobalTransform,
Option<&TargetCamera>, Option<&UiTargetCamera>,
)>, )>,
>, >,
mapping: Extract<Query<RenderEntity>>, mapping: Extract<Query<RenderEntity>>,
@ -82,7 +82,8 @@ pub fn extract_debug_overlay(
continue; continue;
} }
let Some(camera_entity) = camera.map(TargetCamera::entity).or(default_camera_entity) else { let Some(camera_entity) = camera.map(UiTargetCamera::entity).or(default_camera_entity)
else {
continue; continue;
}; };

View File

@ -10,7 +10,7 @@ mod debug_overlay;
use crate::widget::ImageNode; use crate::widget::ImageNode;
use crate::{ use crate::{
BackgroundColor, BorderColor, BoxShadowSamples, CalculatedClip, ComputedNode, DefaultUiCamera, BackgroundColor, BorderColor, BoxShadowSamples, CalculatedClip, ComputedNode, DefaultUiCamera,
Outline, ResolvedBorderRadius, TargetCamera, UiAntiAlias, Outline, ResolvedBorderRadius, UiAntiAlias, UiTargetCamera,
}; };
use bevy_app::prelude::*; use bevy_app::prelude::*;
use bevy_asset::{load_internal_asset, AssetEvent, AssetId, Assets, Handle}; use bevy_asset::{load_internal_asset, AssetEvent, AssetId, Assets, Handle};
@ -287,7 +287,7 @@ pub fn extract_uinode_background_colors(
&GlobalTransform, &GlobalTransform,
&ViewVisibility, &ViewVisibility,
Option<&CalculatedClip>, Option<&CalculatedClip>,
Option<&TargetCamera>, Option<&UiTargetCamera>,
&BackgroundColor, &BackgroundColor,
)>, )>,
>, >,
@ -297,7 +297,8 @@ pub fn extract_uinode_background_colors(
for (entity, uinode, transform, view_visibility, clip, camera, background_color) in for (entity, uinode, transform, view_visibility, clip, camera, background_color) in
&uinode_query &uinode_query
{ {
let Some(camera_entity) = camera.map(TargetCamera::entity).or(default_camera_entity) else { let Some(camera_entity) = camera.map(UiTargetCamera::entity).or(default_camera_entity)
else {
continue; continue;
}; };
@ -349,7 +350,7 @@ pub fn extract_uinode_images(
&GlobalTransform, &GlobalTransform,
&ViewVisibility, &ViewVisibility,
Option<&CalculatedClip>, Option<&CalculatedClip>,
Option<&TargetCamera>, Option<&UiTargetCamera>,
&ImageNode, &ImageNode,
)>, )>,
>, >,
@ -357,7 +358,8 @@ pub fn extract_uinode_images(
) { ) {
let default_camera_entity = default_ui_camera.get(); let default_camera_entity = default_ui_camera.get();
for (entity, uinode, transform, view_visibility, clip, camera, image) in &uinode_query { for (entity, uinode, transform, view_visibility, clip, camera, image) in &uinode_query {
let Some(camera_entity) = camera.map(TargetCamera::entity).or(default_camera_entity) else { let Some(camera_entity) = camera.map(UiTargetCamera::entity).or(default_camera_entity)
else {
continue; continue;
}; };
@ -439,7 +441,7 @@ pub fn extract_uinode_borders(
&GlobalTransform, &GlobalTransform,
&ViewVisibility, &ViewVisibility,
Option<&CalculatedClip>, Option<&CalculatedClip>,
Option<&TargetCamera>, Option<&UiTargetCamera>,
AnyOf<(&BorderColor, &Outline)>, AnyOf<(&BorderColor, &Outline)>,
)>, )>,
>, >,
@ -459,7 +461,7 @@ pub fn extract_uinode_borders(
) in &uinode_query ) in &uinode_query
{ {
let Some(camera_entity) = maybe_camera let Some(camera_entity) = maybe_camera
.map(TargetCamera::entity) .map(UiTargetCamera::entity)
.or(default_camera_entity) .or(default_camera_entity)
else { else {
continue; continue;
@ -678,7 +680,7 @@ pub fn extract_text_sections(
&GlobalTransform, &GlobalTransform,
&ViewVisibility, &ViewVisibility,
Option<&CalculatedClip>, Option<&CalculatedClip>,
Option<&TargetCamera>, Option<&UiTargetCamera>,
&ComputedTextBlock, &ComputedTextBlock,
&TextLayoutInfo, &TextLayoutInfo,
)>, )>,
@ -701,7 +703,7 @@ pub fn extract_text_sections(
text_layout_info, text_layout_info,
) in &uinode_query ) in &uinode_query
{ {
let Some(camera_entity) = camera.map(TargetCamera::entity).or(default_ui_camera) else { let Some(camera_entity) = camera.map(UiTargetCamera::entity).or(default_ui_camera) else {
continue; continue;
}; };

View File

@ -371,7 +371,7 @@ pub fn extract_ui_material_nodes<M: UiMaterial>(
&MaterialNode<M>, &MaterialNode<M>,
&ViewVisibility, &ViewVisibility,
Option<&CalculatedClip>, Option<&CalculatedClip>,
Option<&TargetCamera>, Option<&UiTargetCamera>,
)>, )>,
>, >,
mapping: Extract<Query<RenderEntity>>, mapping: Extract<Query<RenderEntity>>,
@ -380,7 +380,8 @@ pub fn extract_ui_material_nodes<M: UiMaterial>(
let default_single_camera = default_ui_camera.get(); let default_single_camera = default_ui_camera.get();
for (entity, uinode, transform, handle, view_visibility, clip, camera) in uinode_query.iter() { for (entity, uinode, transform, handle, view_visibility, clip, camera) in uinode_query.iter() {
let Some(camera_entity) = camera.map(TargetCamera::entity).or(default_single_camera) else { let Some(camera_entity) = camera.map(UiTargetCamera::entity).or(default_single_camera)
else {
continue; continue;
}; };

View File

@ -256,7 +256,7 @@ pub fn extract_ui_texture_slices(
&GlobalTransform, &GlobalTransform,
&ViewVisibility, &ViewVisibility,
Option<&CalculatedClip>, Option<&CalculatedClip>,
Option<&TargetCamera>, Option<&UiTargetCamera>,
&ImageNode, &ImageNode,
)>, )>,
>, >,
@ -265,7 +265,8 @@ pub fn extract_ui_texture_slices(
let default_camera_entity = default_ui_camera.get(); let default_camera_entity = default_ui_camera.get();
for (entity, uinode, transform, view_visibility, clip, camera, image) in &slicers_query { for (entity, uinode, transform, view_visibility, clip, camera, image) in &slicers_query {
let Some(camera_entity) = camera.map(TargetCamera::entity).or(default_camera_entity) else { let Some(camera_entity) = camera.map(UiTargetCamera::entity).or(default_camera_entity)
else {
continue; continue;
}; };

View File

@ -2613,9 +2613,9 @@ mod tests {
/// Optional if there is only one camera in the world. Required otherwise. /// Optional if there is only one camera in the world. Required otherwise.
#[derive(Component, Clone, Debug, Reflect, Eq, PartialEq)] #[derive(Component, Clone, Debug, Reflect, Eq, PartialEq)]
#[reflect(Component, Debug, PartialEq)] #[reflect(Component, Debug, PartialEq)]
pub struct TargetCamera(pub Entity); pub struct UiTargetCamera(pub Entity);
impl TargetCamera { impl UiTargetCamera {
pub fn entity(&self) -> Entity { pub fn entity(&self) -> Entity {
self.0 self.0
} }
@ -2625,7 +2625,7 @@ impl TargetCamera {
/// ///
/// This is useful if the [`PrimaryWindow`] has two cameras, one of them used /// This is useful if the [`PrimaryWindow`] has two cameras, one of them used
/// just for debug purposes and the user wants a way to choose the default [`Camera`] /// just for debug purposes and the user wants a way to choose the default [`Camera`]
/// without having to add a [`TargetCamera`] to the root node. /// without having to add a [`UiTargetCamera`] to the root node.
/// ///
/// Another use is when the user wants the Ui to be in another window by default, /// Another use is when the user wants the Ui to be in another window by default,
/// all that is needed is to place this component on the camera /// all that is needed is to place this component on the camera
@ -2649,7 +2649,7 @@ impl TargetCamera {
/// ..Default::default() /// ..Default::default()
/// }, /// },
/// // We add the Marker here so all Ui will spawn in /// // We add the Marker here so all Ui will spawn in
/// // another window if no TargetCamera is specified /// // another window if no UiTargetCamera is specified
/// IsDefaultUiCamera /// IsDefaultUiCamera
/// )); /// ));
/// } /// }

View File

@ -2,7 +2,7 @@
use crate::{ use crate::{
experimental::{UiChildren, UiRootNodes}, experimental::{UiChildren, UiRootNodes},
CalculatedClip, Display, Node, OverflowAxis, TargetCamera, CalculatedClip, Display, Node, OverflowAxis, UiTargetCamera,
}; };
use super::ComputedNode; use super::ComputedNode;
@ -137,10 +137,10 @@ fn update_clipping(
pub fn update_target_camera_system( pub fn update_target_camera_system(
mut commands: Commands, mut commands: Commands,
changed_root_nodes_query: Query< changed_root_nodes_query: Query<
(Entity, Option<&TargetCamera>), (Entity, Option<&UiTargetCamera>),
(With<Node>, Changed<TargetCamera>), (With<Node>, Changed<UiTargetCamera>),
>, >,
node_query: Query<(Entity, Option<&TargetCamera>), With<Node>>, node_query: Query<(Entity, Option<&UiTargetCamera>), With<Node>>,
ui_root_nodes: UiRootNodes, ui_root_nodes: UiRootNodes,
ui_children: UiChildren, ui_children: UiChildren,
) { ) {
@ -148,7 +148,7 @@ pub fn update_target_camera_system(
// and updates done for changed_children_query can overlap with itself or with root_node_query // and updates done for changed_children_query can overlap with itself or with root_node_query
let mut updated_entities = <HashSet<_>>::default(); let mut updated_entities = <HashSet<_>>::default();
// Assuming that TargetCamera is manually set on the root node only, // Assuming that UiTargetCamera is manually set on the root node only,
// update root nodes first, since it implies the biggest change // update root nodes first, since it implies the biggest change
for (root_node, target_camera) in changed_root_nodes_query.iter_many(ui_root_nodes.iter()) { for (root_node, target_camera) in changed_root_nodes_query.iter_many(ui_root_nodes.iter()) {
update_children_target_camera( update_children_target_camera(
@ -161,7 +161,7 @@ pub fn update_target_camera_system(
); );
} }
// If the root node TargetCamera was changed, then every child is updated // If the root node UiTargetCamera was changed, then every child is updated
// by this point, and iteration will be skipped. // by this point, and iteration will be skipped.
// Otherwise, update changed children // Otherwise, update changed children
for (parent, target_camera) in &node_query { for (parent, target_camera) in &node_query {
@ -182,8 +182,8 @@ pub fn update_target_camera_system(
fn update_children_target_camera( fn update_children_target_camera(
entity: Entity, entity: Entity,
camera_to_set: Option<&TargetCamera>, camera_to_set: Option<&UiTargetCamera>,
node_query: &Query<(Entity, Option<&TargetCamera>), With<Node>>, node_query: &Query<(Entity, Option<&UiTargetCamera>), With<Node>>,
ui_children: &UiChildren, ui_children: &UiChildren,
commands: &mut Commands, commands: &mut Commands,
updated_entities: &mut HashSet<Entity>, updated_entities: &mut HashSet<Entity>,
@ -201,7 +201,7 @@ fn update_children_target_camera(
commands.entity(child).try_insert(camera.clone()); commands.entity(child).try_insert(camera.clone());
} }
None => { None => {
commands.entity(child).remove::<TargetCamera>(); commands.entity(child).remove::<UiTargetCamera>();
} }
} }
updated_entities.insert(child); updated_entities.insert(child);

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
ComputedNode, ContentSize, DefaultUiCamera, FixedMeasure, Measure, MeasureArgs, Node, ComputedNode, ContentSize, DefaultUiCamera, FixedMeasure, Measure, MeasureArgs, Node,
NodeMeasure, TargetCamera, UiScale, NodeMeasure, UiScale, UiTargetCamera,
}; };
use bevy_asset::Assets; use bevy_asset::Assets;
use bevy_color::Color; use bevy_color::Color;
@ -255,7 +255,7 @@ pub fn measure_text_system(
&mut ContentSize, &mut ContentSize,
&mut TextNodeFlags, &mut TextNodeFlags,
&mut ComputedTextBlock, &mut ComputedTextBlock,
Option<&TargetCamera>, Option<&UiTargetCamera>,
), ),
With<Node>, With<Node>,
>, >,
@ -269,7 +269,7 @@ pub fn measure_text_system(
for (entity, block, content_size, text_flags, computed, maybe_camera) in &mut text_query { for (entity, block, content_size, text_flags, computed, maybe_camera) in &mut text_query {
let Some(camera_entity) = maybe_camera let Some(camera_entity) = maybe_camera
.map(TargetCamera::entity) .map(UiTargetCamera::entity)
.or(default_camera_entity) .or(default_camera_entity)
else { else {
continue; continue;

View File

@ -84,7 +84,7 @@ fn setup(
// Set up UI // Set up UI
commands commands
.spawn(( .spawn((
TargetCamera(camera), UiTargetCamera(camera),
Node { Node {
width: Val::Percent(100.), width: Val::Percent(100.),
height: Val::Percent(100.), height: Val::Percent(100.),
@ -183,7 +183,7 @@ fn set_camera_viewports(
fn button_system( fn button_system(
interaction_query: Query< interaction_query: Query<
(&Interaction, &TargetCamera, &RotateCamera), (&Interaction, &UiTargetCamera, &RotateCamera),
(Changed<Interaction>, With<Button>), (Changed<Interaction>, With<Button>),
>, >,
mut camera_query: Query<&mut Transform, With<Camera>>, mut camera_query: Query<&mut Transform, With<Camera>>,

View File

@ -335,7 +335,7 @@ fn update_active_cameras(
state: Res<State<CameraActive>>, state: Res<State<CameraActive>>,
camera_2d: Single<(Entity, &mut Camera), With<Camera2d>>, camera_2d: Single<(Entity, &mut Camera), With<Camera2d>>,
camera_3d: Single<(Entity, &mut Camera), (With<Camera3d>, Without<Camera2d>)>, camera_3d: Single<(Entity, &mut Camera), (With<Camera3d>, Without<Camera2d>)>,
mut text: Query<&mut TargetCamera, With<HeaderNode>>, mut text: Query<&mut UiTargetCamera, With<HeaderNode>>,
) { ) {
let (entity_2d, mut cam_2d) = camera_2d.into_inner(); let (entity_2d, mut cam_2d) = camera_2d.into_inner();
let (entity_3d, mut cam_3d) = camera_3d.into_inner(); let (entity_3d, mut cam_3d) = camera_3d.into_inner();
@ -351,7 +351,7 @@ fn update_active_cameras(
}; };
text.iter_mut().for_each(|mut target_camera| { text.iter_mut().for_each(|mut target_camera| {
*target_camera = TargetCamera(active_camera); *target_camera = UiTargetCamera(active_camera);
}); });
} }
@ -376,7 +376,7 @@ fn setup_text(mut commands: Commands, cameras: Query<(Entity, &Camera)>) {
top: Val::Px(5.0), top: Val::Px(5.0),
..Default::default() ..Default::default()
}, },
TargetCamera(active_camera), UiTargetCamera(active_camera),
)) ))
.with_children(|p| { .with_children(|p| {
p.spawn(( p.spawn((

View File

@ -75,7 +75,7 @@ fn setup(
..default() ..default()
}, },
BackgroundColor(GOLD.into()), BackgroundColor(GOLD.into()),
TargetCamera(texture_camera), UiTargetCamera(texture_camera),
)) ))
.with_children(|parent| { .with_children(|parent| {
parent.spawn(( parent.spawn((

View File

@ -73,7 +73,7 @@ fn update(
width: Val::Percent(100.0), width: Val::Percent(100.0),
..default() ..default()
}, },
TargetCamera(camera), UiTargetCamera(camera),
MonitorRef(entity), MonitorRef(entity),
)); ));
} }

View File

@ -58,12 +58,12 @@ fn setup_scene(mut commands: Commands, asset_server: Res<AssetServer>) {
Text::new("First window"), Text::new("First window"),
node.clone(), node.clone(),
// Since we are using multiple cameras, we need to specify which camera UI should be rendered to // Since we are using multiple cameras, we need to specify which camera UI should be rendered to
TargetCamera(first_window_camera), UiTargetCamera(first_window_camera),
)); ));
commands.spawn(( commands.spawn((
Text::new("Second window"), Text::new("Second window"),
node, node,
TargetCamera(second_window_camera), UiTargetCamera(second_window_camera),
)); ));
} }