Function macroquad::file::set_pc_assets_folder
source · [−]pub fn set_pc_assets_folder(path: &str)
Expand description
There are super common project layout like this:
.
├── assets
├── └── nice_texture.png
├── src
├── └── main.rs
└── Cargo.toml
when such a project being run on desktop assets should be referenced as “assets/nice_texture.png”. While on web or android it usually is just “nice_texture.png”. The reason: on PC assets are being referenced relative to current active directory/executable path. In most IDEs its the root of the project. While on, say, android it is:
[package.metadata.android]
assets = "assets"
And therefore on android assets are referenced from the root of “assets” folder.
In the future there going to be some sort of meta-data file for PC as well.
But right now to resolve this situation and keep pathes consistent across platforms
set_pc_assets_folder("assets");
call before first load_file
/load_texture
will allow using same pathes on PC and Android.