From 77c5efc56fd6a2d36a4e8658ac4f339999f88188 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Thu, 5 Sep 2024 09:11:26 -0400 Subject: [PATCH] Basic docs for `Asset` and `VisitAssetDependencies` --- crates/bevy_asset/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/bevy_asset/src/lib.rs b/crates/bevy_asset/src/lib.rs index 23cf06458d249..b3ef6386992a1 100644 --- a/crates/bevy_asset/src/lib.rs +++ b/crates/bevy_asset/src/lib.rs @@ -247,6 +247,13 @@ impl Plugin for AssetPlugin { } } +/// Declares that this type is an asset, +/// which can be loaded and managed by the [`AssetServer`] and stored in [`Assets`] collections. +/// +/// Generally, assets are large, complex, and/or expensive to load from disk, and are often authored by artists or designers. +/// +/// [`TypePath`] is largely used for diagnostic purposes, and should almost always be implemented by deriving [`Reflect`] on your type. +/// [`VisitAssetDependencies`] is used to track asset dependencies, and an implementation automatically generated when deriving [`Asset`]. #[diagnostic::on_unimplemented( message = "`{Self}` is not an `Asset`", label = "invalid `Asset`", @@ -254,6 +261,10 @@ impl Plugin for AssetPlugin { )] pub trait Asset: VisitAssetDependencies + TypePath + Send + Sync + 'static {} +/// This trait defines how to visit the dependencies of an asset. +/// For example, a 3D model might require both textures and meshes to be loaded. +/// +/// Note that this trait is automatically implemented when deriving [`Asset`]. pub trait VisitAssetDependencies { fn visit_dependencies(&self, visit: &mut impl FnMut(UntypedAssetId)); }