mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
doc(asset): fix asset trait example (#9105)
# Objective Fix the example code for the `Asset` trait. ## Solution Add `TypePath` trait on `CustomAsset`. Add a static check.
This commit is contained in:
parent
25c64ec7cf
commit
d5f6d92344
1 changed files with 4 additions and 2 deletions
|
@ -34,14 +34,16 @@ pub trait AssetLoader: Send + Sync + 'static {
|
|||
/// and scripts. In Bevy, an asset is any struct that has an unique type id, as shown below:
|
||||
///
|
||||
/// ```rust
|
||||
/// use bevy_reflect::TypeUuid;
|
||||
/// use bevy_reflect::{TypePath, TypeUuid};
|
||||
/// use serde::Deserialize;
|
||||
///
|
||||
/// #[derive(Debug, Deserialize, TypeUuid)]
|
||||
/// #[derive(Debug, Deserialize, TypeUuid, TypePath)]
|
||||
/// #[uuid = "39cadc56-aa9c-4543-8640-a018b74b5052"]
|
||||
/// pub struct CustomAsset {
|
||||
/// pub value: i32,
|
||||
/// }
|
||||
/// # fn is_asset<T: bevy_asset::Asset>() {}
|
||||
/// # is_asset::<CustomAsset>();
|
||||
/// ```
|
||||
///
|
||||
/// See the `assets/custom_asset.rs` example in the repository for more details.
|
||||
|
|
Loading…
Reference in a new issue