mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 04:33:37 +00:00
Document setting "CARGO_MANIFEST_DIR" for asset root (#1950)
This was nowhere documented inside Bevy. Should I also mention the use case of debugging a project? Closes #810 Co-authored-by: MinerSebas <66798382+MinerSebas@users.noreply.github.com>
This commit is contained in:
parent
e29a899b90
commit
458312236a
2 changed files with 20 additions and 2 deletions
|
@ -212,6 +212,18 @@ impl AssetServer {
|
|||
load_state
|
||||
}
|
||||
|
||||
/// Loads an Asset at the provided relative path.
|
||||
///
|
||||
/// The absolute Path to the asset is "ROOT/ASSET_FOLDER_NAME/path".
|
||||
///
|
||||
/// By default the ROOT is the directory of the Application, but this can be overridden by
|
||||
/// setting the `"CARGO_MANIFEST_DIR"` environment variable (see https://doc.rust-lang.org/cargo/reference/environment-variables.html)
|
||||
/// to another directory. When the application is run through Cargo, then
|
||||
/// `"CARGO_MANIFEST_DIR"` is automatically set to the root folder of your crate (workspace).
|
||||
///
|
||||
/// The name of the asset folder is set inside the
|
||||
/// [`AssetServerSettings`](crate::AssetServerSettings) resource. The default name is
|
||||
/// `"assets"`.
|
||||
pub fn load<'a, T: Asset, P: Into<AssetPath<'a>>>(&self, path: P) -> Handle<T> {
|
||||
self.load_untyped(path).typed()
|
||||
}
|
||||
|
|
|
@ -15,8 +15,14 @@ fn setup(
|
|||
meshes: Res<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
) {
|
||||
// By default AssetServer will load assets from inside the "assets" folder
|
||||
// For example, the next line will load "assets/models/cube/cube.gltf#Mesh0/Primitive0"
|
||||
// By default AssetServer will load assets from inside the "assets" folder.
|
||||
// For example, the next line will load "ROOT/assets/models/cube/cube.gltf#Mesh0/Primitive0",
|
||||
// where "ROOT" is the directory of the Application.
|
||||
//
|
||||
// This can be overridden by setting the "CARGO_MANIFEST_DIR" environment variable (see
|
||||
// https://doc.rust-lang.org/cargo/reference/environment-variables.html)
|
||||
// to another directory. When the Application is run through Cargo, "CARGO_MANIFEST_DIR" is
|
||||
// automatically set to your crate (workspace) root directory.
|
||||
let cube_handle = asset_server.load("models/cube/cube.gltf#Mesh0/Primitive0");
|
||||
let sphere_handle = asset_server.load("models/sphere/sphere.gltf#Mesh0/Primitive0");
|
||||
|
||||
|
|
Loading…
Reference in a new issue