我正在从文件中加载纹理作为 aVec<u8>
并将该数据转换为纹理,当我将该纹理添加到资产资源以获取 aHandle<Texture>
时,它会导致两个错误,第一个来自日志记录系统并说gpu_alloc::block: Memory block wasn't deallocated
第二个(我假设是相关的)是thread 'main' panicked at 'range end index 32896 out of range for slice of length 32768'
。这一切似乎都源于这个代码块
Ok(pak) => {
let mut assets : CurrentlyLoadedAssets = CurrentlyLoadedAssets::default();
for texture in pak.textures {
//Creates texture from data and loads it into the resource for a handle
let texture_asset: Texture = Texture::new(Extent3d { width: 32, height: 32, depth: 1 }, TextureDimension::D2, texture.1, Rgba8UnormSrgb);
//This is causing problems
let texture_handle: Handle<Texture> = textures.add(texture_asset);
println!("Loading: {}", &texture.0);
assets.textures.insert(texture.0, texture_handle);
//Problems end here
}
println!("Done getting assets");
commands.insert_resource(assets);
}
知道我需要改变什么来解决这个问题吗?