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 {
|
SceneBundle {
|
||||||
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
|
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
|
||||||
scene: models
|
scene: models
|
||||||
.get(game_assets.world.id())
|
.get(game_assets.world.clone().unwrap().id())
|
||||||
.expect("main level should have been loaded")
|
.expect("main level should have been loaded")
|
||||||
.scenes[0]
|
.scenes[0]
|
||||||
.clone(),
|
.clone(),
|
||||||
|
@ -20,7 +20,7 @@ pub fn setup_game(
|
|||||||
SceneBundle {
|
SceneBundle {
|
||||||
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
|
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
|
||||||
scene: models
|
scene: models
|
||||||
.get(game_assets.world.id())
|
.get(game_assets.world.clone().unwrap().id())
|
||||||
.expect("main level should have been loaded")
|
.expect("main level should have been loaded")
|
||||||
.scenes[0]
|
.scenes[0]
|
||||||
.clone(),
|
.clone(),
|
||||||
|
@ -20,7 +20,7 @@ pub fn setup_game(
|
|||||||
SceneBundle {
|
SceneBundle {
|
||||||
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
|
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
|
||||||
scene: models
|
scene: models
|
||||||
.get(game_assets.world.id())
|
.get(game_assets.world.clone().unwrap().id())
|
||||||
.expect("main level should have been loaded")
|
.expect("main level should have been loaded")
|
||||||
.scenes[0]
|
.scenes[0]
|
||||||
.clone(),
|
.clone(),
|
||||||
|
@ -21,7 +21,7 @@ pub fn setup_game(
|
|||||||
SceneBundle {
|
SceneBundle {
|
||||||
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
|
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
|
||||||
scene: models
|
scene: models
|
||||||
.get(game_assets.world.id())
|
.get(game_assets.world.clone().unwrap().id())
|
||||||
.expect("main level should have been loaded")
|
.expect("main level should have been loaded")
|
||||||
.scenes[0]
|
.scenes[0]
|
||||||
.clone(),
|
.clone(),
|
||||||
|
@ -21,7 +21,7 @@ pub fn setup_game(
|
|||||||
SceneBundle {
|
SceneBundle {
|
||||||
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
|
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
|
||||||
scene: models
|
scene: models
|
||||||
.get(game_assets.world.id())
|
.get(game_assets.world.clone().unwrap().id())
|
||||||
.expect("main level should have been loaded")
|
.expect("main level should have been loaded")
|
||||||
.scenes[0]
|
.scenes[0]
|
||||||
.clone(),
|
.clone(),
|
||||||
|
@ -76,7 +76,7 @@ pub fn trigger_level_transition(
|
|||||||
} else if target_level == "Level2" {
|
} else if target_level == "Level2" {
|
||||||
level = game_assets.level2.clone().unwrap();
|
level = game_assets.level2.clone().unwrap();
|
||||||
} else {
|
} else {
|
||||||
level = game_assets.world.clone();
|
level = game_assets.world.clone().unwrap();
|
||||||
}
|
}
|
||||||
info!("spawning new level");
|
info!("spawning new level");
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
|
@ -21,7 +21,7 @@ pub fn setup_game(
|
|||||||
SceneBundle {
|
SceneBundle {
|
||||||
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
|
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
|
||||||
scene: models
|
scene: models
|
||||||
.get(game_assets.world.id())
|
.get(game_assets.world.clone().unwrap().id())
|
||||||
.expect("main level should have been loaded")
|
.expect("main level should have been loaded")
|
||||||
.scenes[0]
|
.scenes[0]
|
||||||
.clone(),
|
.clone(),
|
||||||
|
@ -5,8 +5,8 @@ use bevy_asset_loader::prelude::*;
|
|||||||
|
|
||||||
#[derive(AssetCollection, Resource)]
|
#[derive(AssetCollection, Resource)]
|
||||||
pub struct GameAssets {
|
pub struct GameAssets {
|
||||||
#[asset(key = "world")]
|
#[asset(key = "world", optional)]
|
||||||
pub world: Handle<Gltf>,
|
pub world: Option<Handle<Gltf>>,
|
||||||
|
|
||||||
#[asset(key = "world_dynamic", optional)]
|
#[asset(key = "world_dynamic", optional)]
|
||||||
pub world_dynamic: Option<Handle<Gltf>>,
|
pub world_dynamic: Option<Handle<Gltf>>,
|
||||||
@ -16,8 +16,8 @@ pub struct GameAssets {
|
|||||||
#[asset(key = "level2", optional)]
|
#[asset(key = "level2", optional)]
|
||||||
pub level2: Option<Handle<Gltf>>,
|
pub level2: Option<Handle<Gltf>>,
|
||||||
|
|
||||||
#[asset(key = "models", collection(typed, mapped))]
|
#[asset(key = "models", collection(typed, mapped), optional)]
|
||||||
pub models: HashMap<String, Handle<Gltf>>,
|
pub models: Option<HashMap<String, Handle<Gltf>>>,
|
||||||
|
|
||||||
#[asset(key = "materials", collection(typed, mapped), optional)]
|
#[asset(key = "materials", collection(typed, mapped), optional)]
|
||||||
pub materials: Option<HashMap<String, Handle<Gltf>>>,
|
pub materials: Option<HashMap<String, Handle<Gltf>>>,
|
||||||
|
Loading…
Reference in New Issue
Block a user