macro_rules! load_embedded_asset {
(@get: $path: literal, $provider: expr) => { ... };
($provider: expr, $path: literal, $settings: expr) => { ... };
($provider: expr, $path: literal) => { ... };
}
Expand description
Load an embedded asset.
This is useful if the embedded asset in question is not publicly exposed, but you need to use it internally.
§Syntax
This macro takes two arguments and an optional third one:
- The asset source. It may be
AssetServer
,World
orApp
. - The path to the asset to embed, as a string literal.
- Optionally, a closure of the same type as in
AssetServer::load_with_settings
. Consider explicitly typing the closure argument in case of type error.
§Usage
The advantage compared to using directly AssetServer::load
is:
- This also accepts
World
andApp
arguments. - This uses the exact same path as
embedded_asset!
, so you can keep it consistent.
As a rule of thumb:
- If the asset in used in the same module as it is declared using
embedded_asset!
, use this macro. - Otherwise, use
AssetServer::load
.