From f6342a91f947cc5c49be8b3446d8810e1e9f5a83 Mon Sep 17 00:00:00 2001 From: Kanabenki Date: Sun, 28 Jan 2024 12:08:44 +0100 Subject: [PATCH 1/2] Add a getter for asset watching status on `AssetServer` --- crates/bevy_asset/src/server/mod.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/bevy_asset/src/server/mod.rs b/crates/bevy_asset/src/server/mod.rs index 457f5c3940d8f..307d99d29a5de 100644 --- a/crates/bevy_asset/src/server/mod.rs +++ b/crates/bevy_asset/src/server/mod.rs @@ -34,7 +34,7 @@ use thiserror::Error; /// The general process to load an asset is: /// 1. Initialize a new [`Asset`] type with the [`AssetServer`] via [`AssetApp::init_asset`], which will internally call [`AssetServer::register_asset`] /// and set up related ECS [`Assets`] storage and systems. -/// 2. Register one or more [`AssetLoader`]s for that asset with [`AssetApp::init_asset_loader`] +/// 2. Register one or more [`AssetLoader`]s for that asset with [`AssetApp::init_asset_loader`] /// 3. Add the asset to your asset folder (defaults to `assets`). /// 4. Call [`AssetServer::load`] with a path to your asset. /// @@ -128,6 +128,11 @@ impl AssetServer { self.data.sources.get(source.into()) } + /// Whether the [`AssetServer`] watches asset sources and hot reload them. + pub fn watching_for_changes(&self) -> bool { + self.data.infos.read().watching_for_changes + } + /// Registers a new [`AssetLoader`]. [`AssetLoader`]s must be registered before they can be used. pub fn register_loader(&self, loader: L) { let mut loaders = self.data.loaders.write(); @@ -1114,7 +1119,7 @@ enum MaybeAssetLoader { }, } -/// Internal events for asset load results +/// Internal events for asset load results #[allow(clippy::large_enum_variant)] pub(crate) enum InternalAssetEvent { Loaded { From 5a3430e869dc06d6eee31af5c16b496c2b705a53 Mon Sep 17 00:00:00 2001 From: Kanabenki Date: Sun, 28 Jan 2024 14:42:52 +0100 Subject: [PATCH 2/2] Use clearer wording for getter doc Co-authored-by: Mateusz Wachowiak --- crates/bevy_asset/src/server/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_asset/src/server/mod.rs b/crates/bevy_asset/src/server/mod.rs index 307d99d29a5de..f84f7d1e707de 100644 --- a/crates/bevy_asset/src/server/mod.rs +++ b/crates/bevy_asset/src/server/mod.rs @@ -128,7 +128,7 @@ impl AssetServer { self.data.sources.get(source.into()) } - /// Whether the [`AssetServer`] watches asset sources and hot reload them. + /// Returns true if the [`AssetServer`] watches for changes. pub fn watching_for_changes(&self) -> bool { self.data.infos.read().watching_for_changes }