Skip to content
Discussion options

You must be logged in to vote

I believe the issue here is you're dropping the Handle on each frame;

fn get_handle(asset_server: Res<AssetServer>, fonts: Res<Assets<VelloFont>>) {
    // Handle created and loading started
    let handle = asset_server.load::<VelloFont>("...");
    
    let Some(font) = fonts.get(&handle) else {
        // Highly likely the asset hasn't loaded immediately (latency, etc.)
        // Because of that, this function always returns
        warn!("asset does not exist");
        return;
        // Now that we've returned, the Handle is dropped, which causes the load to be cancelled
    };
    // ...
}

Instead, try storing the Handle in a resource (or an Entity as a Component). That way the Ha…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by simbleau
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
A-Assets Load files from disk to use for things like images, models, and sounds O-Web Specific to web (WASM) builds
2 participants
Converted from issue

This discussion was converted from issue #13490 on May 24, 2024 03:12.