Mention in .add_observer() docs that first parameter must be a Trigger (#19315)
# Objective Fix https://github.com/bevyengine/bevy/issues/13860 ## Solution Add note in docs that Trigger must be the first parameter of observer systems
This commit is contained in:
parent
818a8fe154
commit
54c9f03021
@ -1306,6 +1306,8 @@ impl App {
|
|||||||
|
|
||||||
/// Spawns an [`Observer`] entity, which will watch for and respond to the given event.
|
/// Spawns an [`Observer`] entity, which will watch for and respond to the given event.
|
||||||
///
|
///
|
||||||
|
/// `observer` can be any system whose first parameter is a [`Trigger`].
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
@ -1326,7 +1328,7 @@ impl App {
|
|||||||
/// # #[derive(Component)]
|
/// # #[derive(Component)]
|
||||||
/// # struct Friend;
|
/// # struct Friend;
|
||||||
/// #
|
/// #
|
||||||
/// // An observer system can be any system where the first parameter is a trigger
|
///
|
||||||
/// app.add_observer(|trigger: Trigger<Party>, friends: Query<Entity, With<Friend>>, mut commands: Commands| {
|
/// app.add_observer(|trigger: Trigger<Party>, friends: Query<Entity, With<Friend>>, mut commands: Commands| {
|
||||||
/// if trigger.event().friends_allowed {
|
/// if trigger.event().friends_allowed {
|
||||||
/// for friend in friends.iter() {
|
/// for friend in friends.iter() {
|
||||||
|
@ -536,6 +536,8 @@ impl World {
|
|||||||
/// Spawns a "global" [`Observer`] which will watch for the given event.
|
/// Spawns a "global" [`Observer`] which will watch for the given event.
|
||||||
/// Returns its [`Entity`] as a [`EntityWorldMut`].
|
/// Returns its [`Entity`] as a [`EntityWorldMut`].
|
||||||
///
|
///
|
||||||
|
/// `system` can be any system whose first parameter is a [`Trigger`].
|
||||||
|
///
|
||||||
/// **Calling [`observe`](EntityWorldMut::observe) on the returned
|
/// **Calling [`observe`](EntityWorldMut::observe) on the returned
|
||||||
/// [`EntityWorldMut`] will observe the observer itself, which you very
|
/// [`EntityWorldMut`] will observe the observer itself, which you very
|
||||||
/// likely do not want.**
|
/// likely do not want.**
|
||||||
|
@ -1068,6 +1068,8 @@ impl<'w, 's> Commands<'w, 's> {
|
|||||||
/// Spawns an [`Observer`] and returns the [`EntityCommands`] associated
|
/// Spawns an [`Observer`] and returns the [`EntityCommands`] associated
|
||||||
/// with the entity that stores the observer.
|
/// with the entity that stores the observer.
|
||||||
///
|
///
|
||||||
|
/// `observer` can be any system whose first parameter is a [`Trigger`].
|
||||||
|
///
|
||||||
/// **Calling [`observe`](EntityCommands::observe) on the returned
|
/// **Calling [`observe`](EntityCommands::observe) on the returned
|
||||||
/// [`EntityCommands`] will observe the observer itself, which you very
|
/// [`EntityCommands`] will observe the observer itself, which you very
|
||||||
/// likely do not want.**
|
/// likely do not want.**
|
||||||
@ -1075,6 +1077,8 @@ impl<'w, 's> Commands<'w, 's> {
|
|||||||
/// # Panics
|
/// # Panics
|
||||||
///
|
///
|
||||||
/// Panics if the given system is an exclusive system.
|
/// Panics if the given system is an exclusive system.
|
||||||
|
///
|
||||||
|
/// [`Trigger`]: crate::observer::Trigger
|
||||||
pub fn add_observer<E: Event, B: Bundle, M>(
|
pub fn add_observer<E: Event, B: Bundle, M>(
|
||||||
&mut self,
|
&mut self,
|
||||||
observer: impl IntoObserverSystem<E, B, M>,
|
observer: impl IntoObserverSystem<E, B, M>,
|
||||||
|
Loading…
Reference in New Issue
Block a user