Open nerdachse opened 8 months ago
I am sorry, here is a better example, that doesn't rely on any image for the button:
fn setup(mut cmd: Commands, ass: Res<AssetServer>) {
cmd.spawn((NodeBundle {
style: Style {
width: Val::Percent(100.0),
height: Val::Percent(100.0),
align_items: AlignItems::Center,
justify_content: JustifyContent::Center,
..default()
},
..default()
},))
.with_children(|parent| {
parent
.spawn((ButtonBundle {
style: Style {
width: Val::Px(300.0),
height: Val::Px(100.0),
// horizontally center child text
justify_content: JustifyContent::Center,
// vertically center child text
align_items: AlignItems::Center,
margin: UiRect::all(Val::Px(20.0)),
..default()
},
..default()
},))
.with_children(|parent| {
parent.spawn(TextBundle::from_section(
"Play",
TextStyle {
font: ass.load("fonts/FiraSans-Bold.ttf"),
font_size: 40.0,
color: Color::rgb(0.9, 0.9, 0.9),
},
));
});
});
}
With UI camera spawned:
Without UI camera spawned:
Potentially related: https://discord.com/channels/691052431525675048/1212672226449555486/1212672226449555486 (frustum of the second camera seems to override the visibility set by the first one)
Bevy version
0.13
Just in case it doesn't happen for someone - I don't think so, but better save than sorry:
What you did
I want to render a menu on top of a "scene" (not a bevy scene) - Right now that's for an "interactive" main-menu... I want a background "video" (actually just a small example world rendered where the camera moves around)
I want to add TWO cameras
I want to have that distinction - especially since I want to add some specific cursor-images to my HUD and it's way easier with
viewport_to_world_2d
.main.rs
Cargo.toml
What went wrong
The problem: When I add the Camera2d with
order: 2
(so it renders on top of the Camera3d) andclear_color = ClearColorConfig::None;
there is a black background:If I do NOT spawn the camera2d:
Then it looks like this:
The UI is rendered on top of the 3d camera which renders an unlighted Sphere.