bevy
bevy copied to clipboard
LoadContext.get_handle() returns invalid or dropped handles
Bevy version
0.6.1
Operating system & version
Windows 10
What you did
-
Create a custom
AssetLoader
-
Create sub-asset resources, such as
StandardMaterial
s, and save them to the currentLoadContext
viaload_context.set_labeled_asset(label, LoadedAsset::new(asset))
-
Reference these sub-asset resources via
let path = AssetPath::new_ref(load_context.path(), Some(label))
-
Get a handle to the resource at the path
load_context.get_handle(path)
-
Spawn entities with these handles
Repro documented in https://github.com/agg23/bevy_loadcontext_example
What you expected to happen
With the bug repro code above, we would expect to see a 10x10 grid of cubes of various colors (StandardMaterial
s) every time the program is run:
What actually happened
However, this complete grid appears rarely, and most of the time, many materials don't render:
Inspecting using bevy_editor_pls
shows the entities as we'd expect, but the material handles don't resolve to anything: