Hi folks, I am really stuck, and might be missing something obvious: I keep having gltf files unloaded right after they finished loading,
- my Gltf handle inside a resource is a strong handle
- and from what I read a handle does not get dropped as long as at least a single strong handle still exists ?
- from the console debugging I can see the gltf load state going
loading=>loaded=>unloaded - stranger still, the
AssetEvent::Createdseems to fire after the asset is unloaded ??
Any ideas would be very welcome, thanks ! ๐
I created a minimal error reproduction (see below);
fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(AssetPlugin {
..default()
}),
))
.add_systems(Startup, setup)
.add_systems(Update, track_creation)
.add_systems(Update, track_loadstate)
.run();
}
#[derive(Resource)]
pub struct MyGltf ( pub Handle<Gltf> );
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.insert_resource(MyGltf(asset_server.load("animation/models/World.glb#Scene0")));
}
fn track_creation(
mut events: EventReader<AssetEvent<Gltf>>,
) {
for event in events.iter() {
if let AssetEvent::Created { handle } = event {
info!("gltf created {:?}", handle.clone());
}
}
}
fn track_loadstate(
asset_server: Res<AssetServer>,
bla: ResMut<MyGltf>
){
info!(
"checking for loaded gltfs {:?}",
asset_server.get_load_state(&bla.0)
);
}```