Skip to content

Commit bce1dac

Browse files
committed
Rename with_child into spawn_child
1 parent 0c90f04 commit bce1dac

27 files changed

+56
-36
lines changed

crates/bevy_dev_tools/src/fps_overlay.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ fn setup(
175175
FpsText,
176176
Pickable::IGNORE,
177177
))
178-
.with_child((TextSpan::default(), overlay_config.text_config.clone()));
178+
.spawn_child((TextSpan::default(), overlay_config.text_config.clone()));
179179

180180
let font_size = overlay_config.text_config.font_size;
181181
p.spawn((

crates/bevy_ecs/src/hierarchy.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,17 @@ impl<'w> EntityWorldMut<'w> {
372372
/// For efficient spawning of multiple children, use [`with_children`].
373373
///
374374
/// [`with_children`]: EntityWorldMut::with_children
375+
#[deprecated = "Use spawn_child instead"]
375376
pub fn with_child(&mut self, bundle: impl Bundle) -> &mut Self {
377+
self.spawn_child(bundle)
378+
}
379+
380+
/// Spawns the passed bundle and adds it to this entity as a child.
381+
///
382+
/// For efficient spawning of multiple children, use [`with_children`].
383+
///
384+
/// [`with_children`]: EntityWorldMut::with_children
385+
pub fn spawn_child(&mut self, bundle: impl Bundle) -> &mut Self {
376386
let parent = self.id();
377387
self.world_scope(|world| {
378388
world.spawn((bundle, ChildOf(parent)));
@@ -484,7 +494,17 @@ impl<'a> EntityCommands<'a> {
484494
/// For efficient spawning of multiple children, use [`with_children`].
485495
///
486496
/// [`with_children`]: EntityCommands::with_children
497+
#[deprecated = "Use spawn_child instead"]
487498
pub fn with_child(&mut self, bundle: impl Bundle) -> &mut Self {
499+
self.spawn_child(bundle)
500+
}
501+
502+
/// Spawns the passed bundle and adds it to this entity as a child.
503+
///
504+
/// For efficient spawning of multiple children, use [`with_children`].
505+
///
506+
/// [`with_children`]: EntityCommands::with_children
507+
pub fn spawn_child(&mut self, bundle: impl Bundle) -> &mut Self {
488508
self.with_related::<ChildOf>(bundle);
489509
self
490510
}

crates/bevy_ui/src/experimental/ghost_hierarchy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,16 @@ mod tests {
217217
parent.spawn((A(2), Node::default()));
218218
parent
219219
.spawn((A(3), GhostNode))
220-
.with_child((A(4), Node::default()));
220+
.spawn_child((A(4), Node::default()));
221221
});
222222

223223
// Ghost root
224224
world.spawn((A(5), GhostNode)).with_children(|parent| {
225225
parent.spawn((A(6), Node::default()));
226226
parent
227227
.spawn((A(7), GhostNode))
228-
.with_child((A(8), Node::default()))
229-
.with_child(A(9));
228+
.spawn_child((A(8), Node::default()))
229+
.spawn_child(A(9));
230230
});
231231

232232
let mut system_state = SystemState::<(UiRootNodes, Query<&A>)>::new(world);

crates/bevy_ui/src/layout/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ mod tests {
685685
let world = app.world_mut();
686686

687687
// spawn an invalid UI root node
688-
let root_node = world.spawn(()).with_child(Node::default()).id();
688+
let root_node = world.spawn(()).spawn_child(Node::default()).id();
689689

690690
app.update();
691691
let world = app.world_mut();

examples/3d/spherical_area_lights.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn setup(
5757
Transform::from_xyz(position_range.start + percent * pos_len, 0.3, 0.0)
5858
.with_scale(Vec3::splat(radius)),
5959
))
60-
.with_child(PointLight {
60+
.spawn_child(PointLight {
6161
radius,
6262
color: Color::srgb(0.2, 0.2, 1.0),
6363
..default()

examples/camera/first_person_view_model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ fn spawn_text(mut commands: Commands) {
195195
left: px(12),
196196
..default()
197197
})
198-
.with_child(Text::new(concat!(
198+
.spawn_child(Text::new(concat!(
199199
"Move the camera with your mouse.\n",
200200
"Press arrow up to decrease the FOV of the world model.\n",
201201
"Press arrow down to increase the FOV of the world model."

examples/ecs/error_handling.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fn setup(
110110

111111
// Add sample points as children of the sphere:
112112
for point in distribution.sample_iter(&mut seeded_rng).take(10000) {
113-
sphere.with_child((
113+
sphere.spawn_child((
114114
Mesh3d(point_mesh.clone()),
115115
MeshMaterial3d(point_material.clone()),
116116
Transform::from_translation(point),

examples/ecs/iter_combinations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ fn generate_bodies(
107107
Transform::from_scale(Vec3::splat(star_radius)),
108108
Star,
109109
))
110-
.with_child(PointLight {
110+
.spawn_child(PointLight {
111111
color: Color::WHITE,
112112
range: 100.0,
113113
radius: star_radius,

examples/games/contributors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
156156
..default()
157157
},
158158
))
159-
.with_child((
159+
.spawn_child((
160160
TextSpan::default(),
161161
TextFont {
162162
font_size: 30.,

examples/games/loading_screen.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fn setup(mut commands: Commands) {
9090
},
9191
BackgroundColor(Color::NONE),
9292
))
93-
.with_child((Text::new("Press 1 or 2 to load a new scene."), text_style));
93+
.spawn_child((Text::new("Press 1 or 2 to load a new scene."), text_style));
9494
}
9595

9696
// Selects the level you want to load.
@@ -256,7 +256,7 @@ fn load_loading_screen(mut commands: Commands) {
256256
BackgroundColor(Color::BLACK),
257257
LoadingScreen,
258258
))
259-
.with_child((Text::new("Loading..."), text_style.clone()));
259+
.spawn_child((Text::new("Loading..."), text_style.clone()));
260260
}
261261

262262
// Determines when to show the loading screen

0 commit comments

Comments
 (0)