Skip to content

Commit dad379c

Browse files
Kanabenkimatiqo15
andauthored
Add a getter for asset watching status on AssetServer (#11578)
# Objective - Closes #11490. - Allow retrieving the current asset watch behavior from the `AssetServer`. ## Solution - Add the corresponding getter. (also fixes some trailing whitespace). A corresponding helper could also be added on the `AssetPlugin` struct (returning `self.watch_for_changes_override.unwrap_or(cfg!(feature = "watch"))`), but it seems it isn't a current practice to have actual methods on the plugin structs appart from the `Plugin` impl. --- ## Changelog ### Added Added `watching_for_changes` getter on `AssetServer`. --------- Co-authored-by: Mateusz Wachowiak <[email protected]>
1 parent 8851532 commit dad379c

File tree

1 file changed

+7
-2
lines changed
  • crates/bevy_asset/src/server

1 file changed

+7
-2
lines changed

crates/bevy_asset/src/server/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use thiserror::Error;
3434
/// The general process to load an asset is:
3535
/// 1. Initialize a new [`Asset`] type with the [`AssetServer`] via [`AssetApp::init_asset`], which will internally call [`AssetServer::register_asset`]
3636
/// and set up related ECS [`Assets`] storage and systems.
37-
/// 2. Register one or more [`AssetLoader`]s for that asset with [`AssetApp::init_asset_loader`]
37+
/// 2. Register one or more [`AssetLoader`]s for that asset with [`AssetApp::init_asset_loader`]
3838
/// 3. Add the asset to your asset folder (defaults to `assets`).
3939
/// 4. Call [`AssetServer::load`] with a path to your asset.
4040
///
@@ -128,6 +128,11 @@ impl AssetServer {
128128
self.data.sources.get(source.into())
129129
}
130130

131+
/// Returns true if the [`AssetServer`] watches for changes.
132+
pub fn watching_for_changes(&self) -> bool {
133+
self.data.infos.read().watching_for_changes
134+
}
135+
131136
/// Registers a new [`AssetLoader`]. [`AssetLoader`]s must be registered before they can be used.
132137
pub fn register_loader<L: AssetLoader>(&self, loader: L) {
133138
let mut loaders = self.data.loaders.write();
@@ -1114,7 +1119,7 @@ enum MaybeAssetLoader {
11141119
},
11151120
}
11161121

1117-
/// Internal events for asset load results
1122+
/// Internal events for asset load results
11181123
#[allow(clippy::large_enum_variant)]
11191124
pub(crate) enum InternalAssetEvent {
11201125
Loaded {

0 commit comments

Comments
 (0)