You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Patterned after this example, I tried to make an on-load event for a gLTF scene. The code:
use bevy::{asset::LoadState, prelude::*};fnmain(){App::build().init_resource::<AssetHandles>().add_plugins(DefaultPlugins).add_resource(State::new(AssetState::Loading)).add_stage_after(stage::UPDATE,"assets",StateStage::<AssetState>::default()).on_state_enter("assets",AssetState::Loading, load_assets.system()).on_state_update("assets",AssetState::Loading, check_assets.system()).on_state_enter("assets",AssetState::Finished, init_assets.system()).run();}#[derive(Clone)]enumAssetState{Loading,Finished,}[derive(Default)]structAssetHandles{scene:Handle<Scene>,}fnload_assets(commands:&mutCommands,mutasset_handles:ResMut<AssetHandles>,asset_server:Res<AssetServer>,){
asset_handles.scene = asset_server.load("models/Monkey.gltf#Scene0");
commands.spawn_scene(asset_handles.scene.clone());}fncheck_assets(mutstate:ResMut<State<AssetState>>,asset_handles:ResMut<AssetHandles>,asset_server:Res<AssetServer>,){ifletLoadState::Loaded = asset_server.get_load_state(&asset_handles.scene){
state.set_next(AssetState::Finished).unwrap();}}fninit_assets(asset_handles:Res<AssetHandles>,scenes:ResMut<Assets<Scene>>,){let scene = scenes.get(&asset_handles.scene).unwrap();}
What you expected to happen
The scenes.get(...) call should return Some.
What actually happened
The scenes.get(...) call returned None, suggesting that the asset was not actually loaded (or that I'm using the API incorrectly somehow?).
The text was updated successfully, but these errors were encountered:
willcrichton
changed the title
Asset server load state not working for gLTF scenes
Asset server load state not working for individual assets
Jan 1, 2021
After some debugging, if I use load_folder and HandleUntyped then the program works as expected. It seems the issue is not with gLTF, but rather loading individual assets vs. a folder of assets.
Adding the #Scene0 to load a scene from a gltf file is a recent change, and was not needed in bevy 0.4, check the load_gltf.rs example from the release (instead of the current one - you can see the difference)
Moxinilian
added
A-Assets
Load files from disk to use for things like images, models, and sounds
C-Bug
An unexpected or incorrect behavior
labels
Jan 4, 2021
Bevy version
0.4.0
Operating system & version
OSX
What you did
Patterned after this example, I tried to make an on-load event for a gLTF scene. The code:
What you expected to happen
The
scenes.get(...)
call should returnSome
.What actually happened
The
scenes.get(...)
call returnedNone
, suggesting that the asset was not actually loaded (or that I'm using the API incorrectly somehow?).The text was updated successfully, but these errors were encountered: