add loading scenes to tx

This commit is contained in:
Schrottkatze 2025-06-22 19:36:37 +02:00
parent f2fc8f41da
commit 4ed1c7d881
Signed by: schrottkatze
SSH key fingerprint: SHA256:FPOYVeBy3QP20FEM42uWF1Wa/Qhlk+L3S2+Wuau/Auo
5 changed files with 38 additions and 3 deletions

26
src/game/debug.rs Normal file
View 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));
}
}
}