//! This example illustrates how to react to component and resource changes. use bevy::prelude::*; use rand::Rng; fn main() { App::new() .add_plugins(DefaultPlugins) .add_systems(Startup, setup) .add_systems( Update, ( change_component, change_component_2, change_resource, change_detection, ), ) .run(); } #[derive(Component, PartialEq, Debug)] struct MyComponent(f32); #[derive(Resource, PartialEq, Debug)] struct MyResource(f32); fn setup(mut commands: Commands) { // Note the first change detection log correctly points to this line because the component is // added. Although commands are deferred, they are able to track the original calling location. commands.spawn(MyComponent(0.0)); commands.insert_resource(MyResource(0.0)); } fn change_component(time: Res