mirror of
https://codeberg.org/schrottkatze/mgd2-tram-championships.git
synced 2025-07-05 03:17:39 +00:00
add loading scenes to tx
This commit is contained in:
parent
f2fc8f41da
commit
4ed1c7d881
5 changed files with 38 additions and 3 deletions
26
src/game/debug.rs
Normal file
26
src/game/debug.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
use bevy::{asset::AssetPath, prelude::*};
|
||||
|
||||
use crate::debug::{ConsoleLog, DebugEvent, DebugMode};
|
||||
|
||||
pub fn plugin(app: &mut App) {
|
||||
app.add_systems(
|
||||
Update,
|
||||
handle_load_gltf.run_if(in_state(DebugMode::Enabled)),
|
||||
);
|
||||
}
|
||||
|
||||
fn handle_load_gltf(
|
||||
mut c: Commands,
|
||||
mut dbg_reader: EventReader<DebugEvent>,
|
||||
mut logger: ResMut<ConsoleLog>,
|
||||
asset_server: Res<AssetServer>,
|
||||
) {
|
||||
for ev in dbg_reader.read() {
|
||||
if let DebugEvent::LoadGltf { asset_path } = ev {
|
||||
let scene_handle = asset_server
|
||||
.load(GltfAssetLabel::Scene(0).from_asset(AssetPath::from(asset_path.clone())));
|
||||
|
||||
c.spawn(SceneRoot(scene_handle));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue