mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-11-26 21:37:01 +00:00
refactor(): made the various gltf assets loaded by bevy_asset_loader optional (to handle the case where they are not present)
* updated all examples accordingly
This commit is contained in:
parent
ea41c3c9cb
commit
5192518b12
@ -30,7 +30,7 @@ pub fn setup_game(
|
||||
SceneBundle {
|
||||
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
|
||||
scene: models
|
||||
.get(game_assets.world.id())
|
||||
.get(game_assets.world.clone().unwrap().id())
|
||||
.expect("main level should have been loaded")
|
||||
.scenes[0]
|
||||
.clone(),
|
||||
|
@ -20,7 +20,7 @@ pub fn setup_game(
|
||||
SceneBundle {
|
||||
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
|
||||
scene: models
|
||||
.get(game_assets.world.id())
|
||||
.get(game_assets.world.clone().unwrap().id())
|
||||
.expect("main level should have been loaded")
|
||||
.scenes[0]
|
||||
.clone(),
|
||||
|
@ -20,7 +20,7 @@ pub fn setup_game(
|
||||
SceneBundle {
|
||||
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
|
||||
scene: models
|
||||
.get(game_assets.world.id())
|
||||
.get(game_assets.world.clone().unwrap().id())
|
||||
.expect("main level should have been loaded")
|
||||
.scenes[0]
|
||||
.clone(),
|
||||
|
@ -21,7 +21,7 @@ pub fn setup_game(
|
||||
SceneBundle {
|
||||
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
|
||||
scene: models
|
||||
.get(game_assets.world.id())
|
||||
.get(game_assets.world.clone().unwrap().id())
|
||||
.expect("main level should have been loaded")
|
||||
.scenes[0]
|
||||
.clone(),
|
||||
|
@ -21,7 +21,7 @@ pub fn setup_game(
|
||||
SceneBundle {
|
||||
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
|
||||
scene: models
|
||||
.get(game_assets.world.id())
|
||||
.get(game_assets.world.clone().unwrap().id())
|
||||
.expect("main level should have been loaded")
|
||||
.scenes[0]
|
||||
.clone(),
|
||||
|
@ -76,7 +76,7 @@ pub fn trigger_level_transition(
|
||||
} else if target_level == "Level2" {
|
||||
level = game_assets.level2.clone().unwrap();
|
||||
} else {
|
||||
level = game_assets.world.clone();
|
||||
level = game_assets.world.clone().unwrap();
|
||||
}
|
||||
info!("spawning new level");
|
||||
commands.spawn((
|
||||
|
@ -21,7 +21,7 @@ pub fn setup_game(
|
||||
SceneBundle {
|
||||
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
|
||||
scene: models
|
||||
.get(game_assets.world.id())
|
||||
.get(game_assets.world.clone().unwrap().id())
|
||||
.expect("main level should have been loaded")
|
||||
.scenes[0]
|
||||
.clone(),
|
||||
|
@ -5,8 +5,8 @@ use bevy_asset_loader::prelude::*;
|
||||
|
||||
#[derive(AssetCollection, Resource)]
|
||||
pub struct GameAssets {
|
||||
#[asset(key = "world")]
|
||||
pub world: Handle<Gltf>,
|
||||
#[asset(key = "world", optional)]
|
||||
pub world: Option<Handle<Gltf>>,
|
||||
|
||||
#[asset(key = "world_dynamic", optional)]
|
||||
pub world_dynamic: Option<Handle<Gltf>>,
|
||||
@ -16,8 +16,8 @@ pub struct GameAssets {
|
||||
#[asset(key = "level2", optional)]
|
||||
pub level2: Option<Handle<Gltf>>,
|
||||
|
||||
#[asset(key = "models", collection(typed, mapped))]
|
||||
pub models: HashMap<String, Handle<Gltf>>,
|
||||
#[asset(key = "models", collection(typed, mapped), optional)]
|
||||
pub models: Option<HashMap<String, Handle<Gltf>>>,
|
||||
|
||||
#[asset(key = "materials", collection(typed, mapped), optional)]
|
||||
pub materials: Option<HashMap<String, Handle<Gltf>>>,
|
||||
|
Loading…
Reference in New Issue
Block a user