From 7132404b38c993bfabd509113c4c49b7c2b18701 Mon Sep 17 00:00:00 2001 From: Torstein Grindvik <52322338+torsteingrindvik@users.noreply.github.com> Date: Fri, 20 Oct 2023 16:43:16 +0200 Subject: [PATCH] Add note about asset source register order (#10186) # Objective I encountered a problem where I had a plugin `FooPlugin` which did ```rust impl Plugin for FooPlugin { fn build(&self, app: &mut App) { app .register_asset_source(...); // more stuff after } } ``` And when I tried using it, e.g. ```rust asset_server.load("foo://data/asset.custom"); ``` I got an error that `foo` was not recognized as a source. I found that this is because asset sources must be registered _before_ `AssetPlugin` is added, and I had `FooPlugin` _after_. ## Solution Add clarifying note about having to register sources before `AssetPlugin` is added. Signed-off-by: Torstein Grindvik Co-authored-by: Torstein Grindvik --- crates/bevy_asset/src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/bevy_asset/src/lib.rs b/crates/bevy_asset/src/lib.rs index 291e18b43b..8787d604cc 100644 --- a/crates/bevy_asset/src/lib.rs +++ b/crates/bevy_asset/src/lib.rs @@ -243,6 +243,9 @@ pub trait AssetApp { /// Registers the given `processor` in the [`App`]'s [`AssetProcessor`]. fn register_asset_processor(&mut self, processor: P) -> &mut Self; /// Registers the given [`AssetSourceBuilder`] with the given `id`. + /// + /// Note that asset sources must be registered before adding [`AssetPlugin`] to your application, + /// since registered asset sources are built at that point and not after. fn register_asset_source( &mut self, id: impl Into>,