Document EntityCommands/EntityMut insert() (#6270)

Fixes #6258.
This commit is contained in:
JMS55 2022-10-17 14:38:58 +00:00
parent bfbcd47725
commit 708535536b
2 changed files with 6 additions and 1 deletions

View File

@ -321,7 +321,7 @@ impl<'w, 's> Commands<'w, 's> {
/// if let Some(mut entity_commands) = commands.get_entity(entity) { /// if let Some(mut entity_commands) = commands.get_entity(entity) {
/// // adds a single component to the entity /// // adds a single component to the entity
/// entity_commands.insert(Label("hello world")); /// entity_commands.insert(Label("hello world"));
/// } /// }
/// } /// }
/// # bevy_ecs::system::assert_is_system(example_system); /// # bevy_ecs::system::assert_is_system(example_system);
/// ``` /// ```
@ -565,6 +565,8 @@ impl<'w, 's, 'a> EntityCommands<'w, 's, 'a> {
/// Adds a [`Bundle`] of components to the entity. /// Adds a [`Bundle`] of components to the entity.
/// ///
/// This will overwrite any previous value(s) of the same component type.
///
/// # Panics /// # Panics
/// ///
/// The command will panic when applied if the associated entity does not exist. /// The command will panic when applied if the associated entity does not exist.

View File

@ -246,6 +246,9 @@ impl<'w> EntityMut<'w> {
self.insert(bundle) self.insert(bundle)
} }
/// Adds a [`Bundle`] of components to the entity.
///
/// This will overwrite any previous value(s) of the same component type.
pub fn insert<T: Bundle>(&mut self, bundle: T) -> &mut Self { pub fn insert<T: Bundle>(&mut self, bundle: T) -> &mut Self {
let change_tick = self.world.change_tick(); let change_tick = self.world.change_tick();
let bundle_info = self let bundle_info = self