use relative paths for assets

This commit is contained in:
Carter Anderson 2020-05-14 15:25:43 -07:00
parent 2bcb8a2a41
commit 8a61ef48d3
9 changed files with 11 additions and 24 deletions

View file

@ -12,8 +12,7 @@ fn setup(
mut textures: ResMut<Assets<Texture>>,
mut materials: ResMut<Assets<ColorMaterial>>,
) {
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

View file

@ -13,8 +13,7 @@ fn setup(
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// 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

View file

@ -15,11 +15,9 @@ fn setup(
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// 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);

View file

@ -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();
}

View file

@ -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,

View file

@ -13,11 +13,7 @@ fn setup(
mut textures: ResMut<Assets<Texture>>,
mut materials: ResMut<Assets<ColorMaterial>>,
) {
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();

View file

@ -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);