load_embedded_asset

Macro load_embedded_asset 

Source
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:

  1. The asset source. It may be AssetServer, World or App.
  2. The path to the asset to embed, as a string literal.
  3. 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 and App 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.