Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a getter for asset watching status on AssetServer #11578

Merged
merged 2 commits into from
Jan 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions crates/bevy_asset/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -128,6 +128,11 @@ impl AssetServer {
self.data.sources.get(source.into())
}

/// Whether the [`AssetServer`] watches asset sources and hot reload them.
Kanabenki marked this conversation as resolved.
Show resolved Hide resolved
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<L: AssetLoader>(&self, loader: L) {
let mut loaders = self.data.loaders.write();
Expand Down Expand Up @@ -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 {
Expand Down