From 8a61ef48d3f2acff97c404e57c5f677e88190874 Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Thu, 14 May 2020 15:25:43 -0700 Subject: [PATCH] use relative paths for assets --- assets/models/{ => monkey}/Monkey.bin | Bin assets/models/{ => monkey}/Monkey.gltf | 0 examples/2d/sprite.rs | 3 +-- examples/3d/load_model.rs | 3 +-- examples/3d/texture.rs | 8 +++----- examples/app/dynamic_plugin_loading/main.rs | 5 +---- examples/app/plugin.rs | 2 +- examples/ui/text.rs | 6 +----- examples/ui/ui.rs | 8 +++----- 9 files changed, 11 insertions(+), 24 deletions(-) rename assets/models/{ => monkey}/Monkey.bin (100%) rename assets/models/{ => monkey}/Monkey.gltf (100%) diff --git a/assets/models/Monkey.bin b/assets/models/monkey/Monkey.bin similarity index 100% rename from assets/models/Monkey.bin rename to assets/models/monkey/Monkey.bin diff --git a/assets/models/Monkey.gltf b/assets/models/monkey/Monkey.gltf similarity index 100% rename from assets/models/Monkey.gltf rename to assets/models/monkey/Monkey.gltf diff --git a/examples/2d/sprite.rs b/examples/2d/sprite.rs index 7a506ec0ce..62cef7e404 100644 --- a/examples/2d/sprite.rs +++ b/examples/2d/sprite.rs @@ -12,8 +12,7 @@ fn setup( mut textures: ResMut>, mut materials: ResMut>, ) { - let texture_path = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/branding/icon.png"); - let texture = Texture::load(TextureType::Png(texture_path.to_string())); + let texture = Texture::load(TextureType::Png("assets/branding/icon.png".to_string())); let texture_handle = textures.add(texture); command_buffer diff --git a/examples/3d/load_model.rs b/examples/3d/load_model.rs index 5831222aa3..884fb81d41 100644 --- a/examples/3d/load_model.rs +++ b/examples/3d/load_model.rs @@ -13,8 +13,7 @@ fn setup( mut materials: ResMut>, ) { // load the mesh - let model_path = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/models/Monkey.gltf"); - let mesh = gltf::load_gltf(&model_path).unwrap().unwrap(); + let mesh = gltf::load_gltf("assets/models/monkey/Monkey.gltf").unwrap().unwrap(); let mesh_handle = meshes.add(mesh); // create a material for the mesh diff --git a/examples/3d/texture.rs b/examples/3d/texture.rs index 7fd6977836..7961deeaf6 100644 --- a/examples/3d/texture.rs +++ b/examples/3d/texture.rs @@ -15,11 +15,9 @@ fn setup( mut materials: ResMut>, ) { // load a texture - let texture_path = concat!( - env!("CARGO_MANIFEST_DIR"), - "/assets/branding/bevy_logo_dark_big.png" - ); - let texture = Texture::load(TextureType::Png(texture_path.to_string())); + let texture = Texture::load(TextureType::Png( + "assets/branding/bevy_logo_dark_big.pn".to_string(), + )); let aspect = texture.aspect(); let texture_handle = textures.add(texture); diff --git a/examples/app/dynamic_plugin_loading/main.rs b/examples/app/dynamic_plugin_loading/main.rs index ae1a8f2a4d..fe27d92aef 100644 --- a/examples/app/dynamic_plugin_loading/main.rs +++ b/examples/app/dynamic_plugin_loading/main.rs @@ -3,9 +3,6 @@ use bevy::prelude::*; fn main() { App::build() .add_default_plugins() - .load_plugin(concat!( - env!("CARGO_MANIFEST_DIR"), - "/target/debug/libexample_plugin.so" - )) + .load_plugin("target/debug/libexample_plugin.so") .run(); } diff --git a/examples/app/plugin.rs b/examples/app/plugin.rs index 8ac88f597d..1f06462e4e 100644 --- a/examples/app/plugin.rs +++ b/examples/app/plugin.rs @@ -14,7 +14,7 @@ fn main() { .run(); } -#[derive(Default)] +// This "print message plugin" prints a `message` every `wait_duration` pub struct PrintMessagePlugin { // Put your plugin configuration here wait_duration: Duration, diff --git a/examples/ui/text.rs b/examples/ui/text.rs index c1f958b3c5..b807842dfd 100644 --- a/examples/ui/text.rs +++ b/examples/ui/text.rs @@ -13,11 +13,7 @@ fn setup( mut textures: ResMut>, mut materials: ResMut>, ) { - let font_path = concat!( - env!("CARGO_MANIFEST_DIR"), - "/assets/fonts/FiraSans-Bold.ttf" - ); - let mut font_file = File::open(&font_path).unwrap(); + let mut font_file = File::open("assets/fonts/FiraSans-Bold.ttf").unwrap(); let mut buffer = Vec::new(); font_file.read_to_end(&mut buffer).unwrap(); let font = Font::try_from_bytes(buffer).unwrap(); diff --git a/examples/ui/ui.rs b/examples/ui/ui.rs index 39d4d4c488..d7e8ff6bf9 100644 --- a/examples/ui/ui.rs +++ b/examples/ui/ui.rs @@ -23,11 +23,9 @@ fn setup( // ..Default::default() // }); - let texture_path = concat!( - env!("CARGO_MANIFEST_DIR"), - "/assets/branding/bevy_logo_dark_big.png" - ); - let texture = Texture::load(TextureType::Png(texture_path.to_string())); + let texture = Texture::load(TextureType::Png( + "assets/branding/bevy_logo_dark_big.png".to_string(), + )); let aspect = texture.aspect(); let texture_handle = textures.add(texture);