-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* removed clutter * moved hot reload to seperate module * added back "assets loaded" event, removed useless events * registered HideUntilReady component for users * minor tweaks & cleanups
- Loading branch information
1 parent
bef709a
commit 3099f98
Showing
8 changed files
with
118 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
use bevy::prelude::*; | ||
use bevy::asset::{AssetEvent, LoadedUntypedAsset}; | ||
use bevy::scene::SceneInstance; | ||
use crate::{BlueprintAssetsLoadState, BlueprintAssetsLoaded, BlueprintInfo, SpawnHere}; | ||
|
||
pub(crate) fn react_to_asset_changes( | ||
mut gltf_events: EventReader<AssetEvent<Gltf>>, | ||
mut untyped_events: EventReader<AssetEvent<LoadedUntypedAsset>>, | ||
mut blueprint_assets: Query<(Entity, Option<&Name>, &BlueprintInfo, &mut BlueprintAssetsLoadState, Option<&Children>)>, | ||
asset_server: Res<AssetServer>, | ||
mut commands: Commands, | ||
|
||
) { | ||
|
||
for event in gltf_events.read() { | ||
// LoadedUntypedAsset | ||
match event { | ||
AssetEvent::Modified { id } => { | ||
// React to the image being modified | ||
// println!("Modified gltf {:?}", asset_server.get_path(*id)); | ||
for (entity, entity_name, blueprint_info, mut assets_to_load, children) in blueprint_assets.iter_mut() { | ||
for tracker in assets_to_load.asset_infos.iter_mut() { | ||
if asset_server.get_path(*id).is_some() { | ||
if tracker.path == asset_server.get_path(*id).unwrap().to_string() { | ||
println!("HOLY MOLY IT DETECTS !!, now respawn {:?}", entity_name); | ||
if children.is_some() { | ||
for child in children.unwrap().iter(){ | ||
commands.entity(*child).despawn_recursive(); | ||
} | ||
} | ||
commands.entity(entity) | ||
.remove::<BlueprintAssetsLoaded>() | ||
.remove::<SceneInstance>() | ||
.remove::<BlueprintAssetsLoadState>() | ||
.insert(SpawnHere); | ||
|
||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
} | ||
_ => {} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.