lowenware / dotrix

A 3D engine with ECS and Vulkan renderer for Rust developers
https://dotrix.rs
MIT License
292 stars 11 forks source link

Add a property to control assets root directory #146

Closed voxelias closed 2 years ago

voxelias commented 2 years ago
  1. Adds the root property to Assets service, that defaults to current working directory
  2. Adds method root() to Assets to get value of the property
  3. Adds method set_root() to Assets to set value of the property
  4. Adds method import_from to Assets to keep possibility to import file from anywhere

For iOS applications some startup system should be considered, for example:

fn startup(mut assets: Mut<Assets>) {
  // before loading any asset from FS
  assets.set_root(
    std::env::current_exe()
      .expect("Executable path to be available")
      .parent()
      .unwrap()
  );
}
voxelias commented 2 years ago

Based on the PR #145 from @russellwmy