mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 20:53:53 +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
7c3131a761
commit
cd0a642fa1
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:
|
/// and scripts. In Bevy, an asset is any struct that has an unique type id, as shown below:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use bevy_reflect::TypeUuid;
|
/// use bevy_reflect::{TypePath, TypeUuid};
|
||||||
/// use serde::Deserialize;
|
/// use serde::Deserialize;
|
||||||
///
|
///
|
||||||
/// #[derive(Debug, Deserialize, TypeUuid)]
|
/// #[derive(Debug, Deserialize, TypeUuid, TypePath)]
|
||||||
/// #[uuid = "39cadc56-aa9c-4543-8640-a018b74b5052"]
|
/// #[uuid = "39cadc56-aa9c-4543-8640-a018b74b5052"]
|
||||||
/// pub struct CustomAsset {
|
/// pub struct CustomAsset {
|
||||||
/// pub value: i32,
|
/// 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.
|
/// See the `assets/custom_asset.rs` example in the repository for more details.
|
||||||
|
|
Loading…
Reference in a new issue