Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1b3e938
Store `AssetSource` as Arc in `AssetSources`.
andriyDev Nov 8, 2025
b03e7da
Wrap the `AssetSources` in a `RwLock`.
andriyDev Nov 8, 2025
d081b3d
Allow adding and removing assets, and allow registering sources after…
andriyDev Nov 8, 2025
fc9721e
Fix up regular asset tests to register sources after the AssetPlugin.
andriyDev Nov 8, 2025
f8c06d9
Rewrite asset processing tests to allow adding sources piecemeal.
andriyDev Nov 4, 2025
8e5a8e7
Prevent adding or removing processed asset sources after processing h…
andriyDev Nov 8, 2025
d66f889
Create a test to show that an asset can be loaded from a runtime adde…
andriyDev Nov 8, 2025
8c2db34
Fix up all the dependents and examples to add the default source in t…
andriyDev Nov 8, 2025
e2884d7
Write a test to show that we can't add or remove processed sources af…
andriyDev Nov 9, 2025
46c739d
Create a migration guide for registering asset sources.
andriyDev Nov 9, 2025
552ff0f
Create release notes for runtime asset sources.
andriyDev Nov 9, 2025
a894e11
Reword release notes.
andriyDev Nov 21, 2025
d41d211
Reword error to be a more clear when adding sources at the wrong time.
andriyDev Nov 21, 2025
d2239dd
Clarify blocking on the RwLock around the `started` flag.
andriyDev Nov 21, 2025
80869f7
Provide a from_builder and from_paths method for creating `DefaultAss…
andriyDev Nov 21, 2025
b2c1337
Add PR number to migration guide and release notes.
andriyDev Dec 5, 2025
50cfd0e
Rename `create_source` to `create_processed_source`.
andriyDev Dec 5, 2025
51ca349
Reword comments for AddSourceError and RemoveSourceError.
andriyDev Dec 5, 2025
4938956
Add the source name to AddSourceError::SourceIsProcessed and RemoveSo…
andriyDev Dec 5, 2025
7c05f81
Reuse create_app for tests that need additional sources, now that we …
andriyDev Dec 21, 2025
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
22 changes: 9 additions & 13 deletions crates/bevy_asset/src/io/embedded/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ mod embedded_watcher;

#[cfg(feature = "embedded_watcher")]
pub use embedded_watcher::*;
use tracing::error;

use crate::io::{
memory::{Dir, MemoryAssetReader, Value},
AssetSourceBuilder, AssetSourceBuilders,
AssetSourceBuilder, AssetSources,
};
use crate::AssetServer;
use alloc::boxed::Box;
Expand All @@ -19,8 +20,7 @@ use std::path::{Path, PathBuf};
#[cfg(feature = "embedded_watcher")]
use alloc::borrow::ToOwned;

/// The name of the `embedded` [`AssetSource`](crate::io::AssetSource),
/// as stored in the [`AssetSourceBuilders`] resource.
/// The name of the `embedded` [`AssetSource`](crate::io::AssetSource).
pub const EMBEDDED: &str = "embedded";

/// A [`Resource`] that manages "rust source files" in a virtual in memory [`Dir`], which is intended
Expand Down Expand Up @@ -83,18 +83,12 @@ impl EmbeddedAssetRegistry {
self.dir.remove_asset(full_path)
}

/// Registers the [`EMBEDDED`] [`AssetSource`](crate::io::AssetSource) with the given [`AssetSourceBuilders`].
pub fn register_source(&self, sources: &mut AssetSourceBuilders) {
/// Registers the [`EMBEDDED`] [`AssetSource`](crate::io::AssetSource) with the given
/// [`AssetSources`].
pub fn register_source(&self, sources: &mut AssetSources) {
let dir = self.dir.clone();
let processed_dir = self.dir.clone();

#[cfg_attr(
not(feature = "embedded_watcher"),
expect(
unused_mut,
reason = "Variable is only mutated when `embedded_watcher` feature is enabled."
)
)]
let mut source =
AssetSourceBuilder::new(move || Box::new(MemoryAssetReader { root: dir.clone() }))
.with_processed_reader(move || {
Expand Down Expand Up @@ -132,7 +126,9 @@ impl EmbeddedAssetRegistry {
)))
});
}
sources.insert(EMBEDDED, source);
if let Err(err) = sources.add(EMBEDDED, &mut source) {
error!("Failed to register asset source: {err}");
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/io/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl FileAssetReader {
/// Returns the base path of the assets directory, which is normally the executable's parent
/// directory.
///
/// To change this, set [`AssetPlugin::file_path`][crate::AssetPlugin::file_path].
/// To change this, set [`DefaultAssetSource::Paths::file_path`][crate::DefaultAssetSource::Paths::file_path].
pub fn get_base_path() -> PathBuf {
get_base_path()
}
Expand Down
Loading