File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed
crates/bevy_ecs/src/system Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -1287,10 +1287,32 @@ unsafe impl SystemParam for SystemChangeTick {
12871287 }
12881288}
12891289
1290- /// Name of the system that corresponds to this [`crate::system::SystemState`] .
1290+ /// [`SystemParam`] that returns the name of the system which it is used in .
12911291///
1292- /// This is not a reliable identifier, it is more so useful for debugging
1293- /// purposes of finding where a system parameter is being used incorrectly.
1292+ /// This is not a reliable identifier, it is more so useful for debugging or logging.
1293+ ///
1294+ /// # Examples
1295+ ///
1296+ /// ```
1297+ /// # use bevy_ecs::system::SystemName;
1298+ /// # use bevy_ecs::system::SystemParam;
1299+ ///
1300+ /// #[derive(SystemParam)]
1301+ /// struct Logger<'s> {
1302+ /// system_name: SystemName<'s>,
1303+ /// }
1304+ ///
1305+ /// impl<'s> Logger<'s> {
1306+ /// fn log(&mut self, message: &str) {
1307+ /// eprintln!("{}: {}", self.system_name, message);
1308+ /// }
1309+ /// }
1310+ ///
1311+ /// fn system1(mut logger: Logger) {
1312+ /// // Prints: "crate_name::mod_name::system1: Hello".
1313+ /// logger.log("Hello");
1314+ /// }
1315+ /// ```
12941316#[ derive( Debug ) ]
12951317pub struct SystemName < ' s > ( & ' s str ) ;
12961318
You can’t perform that action at this time.
0 commit comments