Asset is not loaded due to handle being unique, when it's not

#1

Hi everyone,

Using Amethyst 0.11 from crates.io I’m trying to make a simple prefab format which places cuboid platforms in the world, and I’m using the amethyst_rendy::shape::Shape::generate method to get meshes for rendering. Here is my code, in the add_to_entity method on my custom impl PrefabData:

let mesh_handle = mesh_loader.load_from_data(
    RenderShape::Cube.generate::<Vec<PosNormTangTex>>(
        Some((length, 0.125, width))
    ).into(), ()
);
mesh_handles.insert(entity, mesh_handle).map(|_| ())?;

(mesh_loader is AssetLoaderSystemData<Mesh>)

The cuboid does not render and Amethyst prints this error:

[WARN][amethyst_assets::storage] Loading unnecessary asset. Handle 0 is unique 
[ERROR][amethyst_assets::progress] Error loading handle 0, Mesh, with name <Data>: Asset was loaded but no handle to it was saved.
caused by: Asset was loaded but no handle to it was saved.
Error { inner: Inner { source: None, backtrace: None, error: UnusedHandle } }

but the handle is shown here, after the error, as being attached to an entity:

[src/states/play.rs:42] world.read_storage::<Handle<Mesh>>().join().collect::<Vec<_>>() = [
    Handle {
        id: 0,
    },
]

Am I missing some part of the asset loading process? Why isn’t the cuboid rendering?

(Théo Degioanni) #2

Where do you have this code running? Is it standalone or inside a prefab definition?

#3

The code snippet is in the add_to_entity method on a custom impl PrefabData. The second debug log is printed in a new state (the main state) in the on_start method.